Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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!

Tags (1)
1 Solution

Accepted Solutions
mov
Esteemed Contributor III

Re: Fix the last week in a expression

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))


6 Replies
buzzy996
Honored Contributor II

Re: Fix the last week in a expression

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

Re: Fix the last week in a expression

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

mov
Esteemed Contributor III

Re: Fix the last week in a expression

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

Re: Fix the last week in a expression

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!

mov
Esteemed Contributor III

Re: Fix the last week in a expression

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

Re: Fix the last week in a expression

Thanks Michael! you have been very helpful!

Community Browser