Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to use date flags after you created the master calendar?

Hi,

This is a real beginner question.

I have made this standard master calendar (with date island, data variables and the calendar :

... Date... , Mindate, MaxDate.... then

Y AS Year,

M AS Month,

MY AS MonthYear,

num(MY) AS NumericMonthYear,

'Q' & ceil(M / 3) AS Quarter,

D as ...

Then afterwards you have all these CM, LY, YTD ... flags :

...

//Month flags

inmonth(D, $(vToday), 0) * -1 AS CM,  //Current month

inmonth(D, $(vToday), -1) * -1 AS PM,  //Previous month

...

This all works, but how do I use these flags now in my expression?

Let's say I have a field "Quantity", and I would like to see the tonnes for CM and PM in a table, how do I do this?

sum(if(CM=1,Quantity)) or something? I really don't know...

Thanks!!

2 Replies
Not applicable
Author

Try this expresion

sum({$<[CM] = {0}>} Quantity)

I hope to help you

swuehl
MVP
MVP

Essentially, yes, you could use

=sum(if(CM=1,Quantity))

You can also use

=sum(CM*Quantity)

if your flags are created using value 1 for true and 0 for false (like you did).

Instead of the first expression, you can also use a set expression:

=sum( {<CM={1}>} Quantity)

Hope this helps,

Stefan