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

Changing a Variable.

So I am changing a the date on a variable I created in the Variable Overview.

However when I do this my formula stops working and doesn't give me what I want.

Variables are

vMonth = 01/12/2017

vPreviousMonth = 01/11/2017

and my formula to return the number of entries that are in 12/2017 is

=num(sum(if(month.1=vMonth,1,0)),'#,##0')

and for 11/2017:

=num(sum(if(month.1=vPreviousMonth,1,0)),'#,##0')

Any ideas as to why its not working would be greatly appreciated.

Thanks

8 Replies
zebhashmi
Specialist
Specialist

try that

=num(sum(if(month.1=$(vMonth),1,0)),'#,##0')

Anonymous
Not applicable
Author

No that didn't work unfortunately.

I created them in the script now like this:

handlerinfoqvd:
LOAD Team, month,

key1

from $(QVDPath)handlerinfo.qvd (qvd);
Months:
load max(month) as vMonth,
        (
max(month)-1) as vPreviousMonth
from $(QVDPath)handlerinfo.qvd (qvd);

vMonth is working however vPreviousMonth isn't.

tresesco
MVP
MVP

How do the values in your month field look like?

Anonymous
Not applicable
Author

This is handlerinfo.qvd table

tresesco
MVP
MVP

So your month field is actually having date values. Try like:

MonthStart(max(month) , -1)  as vPreviousMonth

Anonymous
Not applicable
Author

No that doesn't seem to work for me but thanks.

I also tried the below but no luck.

handlerinfoqvd:
LOAD Team, month,

key1

from $(QVDPath)handlerinfo.qvd (qvd);
Months:
load max(month) as vMonth,
if(right(max(month),2)='01',max(month)-89,max(month)-1) as vPreviousMonth
from $(QVDPath)handlerinfo.qvd (qvd);

tresesco
MVP
MVP

What is the output you are getting using the statement I suggested? Could you share your qvd with sample data?

Anonymous
Not applicable
Author

The monthstart  worked.

Thank you very much.