Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Fix the last week in a expression


Hi!

I would like to know if is posible this issue:

There is a ítem call "week", every week, the DB is updated with the last week information added.

i want to fix in the scripting of a chart expression only to show the last week information,

Is this posible?

Thanks a lot!

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

In fact - yes.  There is the 4th optional parameter in the InWeek() function for the week start.  Probably it is -2 in your case, but I'm not sure, try to experiment with it:

sum(if(InWeek(Date, today(),0,-2),pax))


View solution in original post

6 Replies
buzzy996
Master II
Master II

week( '1971-10-30' ) returns 43 ---take latest week always.


else play with these

  1. LET vCurrentWeek = week(today()); 
  2. LET vPreviousWeek = week(today()-7); 
  3. LET vCurrentYear = year(today()); 
  4. LET vPreviousYear = year(today()-7);  whichever u need.
Not applicable
Author

No, this does not work, is inside the expression of a table chart:

now I am trying with a week_id that has numbers( 1,2,..53) and fixing in the expression the last week but i do not know how to do the expression

For example if i am in 43 week id and i want (without sellecting in qlikview) inside the expression fix in the chart always the last week i mean the week 42.

Is an stupid example because i dont know how... thanks

sum({$<[week_id]=(week_id -(week_id-1)>}pax


How can i do it in a expression like this? thanks a lot for your support

Anonymous
Not applicable
Author

Do you have a Date field in your data?  If yes, you don't need week id at all, just use condition in the expression to calculate the data for the Dates in the current week, for example

sum(if(InWeek(Date, today(),0),pax))

Not applicable
Author

Thanks Michael. It Works!.. but to complicate more things my weeks are difined from saturday to friday.. Not from monday to sunday .. is there any way to change InWeek in this ranges?

Thanks!

Anonymous
Not applicable
Author

In fact - yes.  There is the 4th optional parameter in the InWeek() function for the week start.  Probably it is -2 in your case, but I'm not sure, try to experiment with it:

sum(if(InWeek(Date, today(),0,-2),pax))


Not applicable
Author

Thanks Michael! you have been very helpful!