Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

One year earlier than selected

Hello

I've got a problem and I have no idea how to solve it - I'm trying to do it for a few hours and still nothing.

I've got dates:

ORDER_DATE

ORDER_DATE_MONTH

ORDER_DATE_YEAR

It's one and the same date, but month and year are made for me to be able to choose month and year separately.

Now - I want to make something like this:

IF(ORDER_DATE_MONTH <= MAX(ORDER_DATE_MONTH) and ORDER_DATE_MONTH >= MIN(ORDER_DATE_MONTH) and ORDER_DATE_YEAR = $(vMaxMonth), SUM(ORDER_QTY), 0)

where vMaxMonth is:

num(MAX(ORDER_DATE_YEAR))

and it works. But when i try to add '-1' to vMaxMonth, it all crashes.

I want to have selected year minus one, but nothing's working.

Have you got any idea how to make it?

4 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Where are you adding the -1?

Here?

....NTH) and ORDER_DATE_YEAR = ($(vMaxMonth) - 1),....


Or here?

vMaxMonth = num(MAX(ORDER_DATE_YEAR) - 1)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jsingh71
Partner - Specialist
Partner - Specialist

For Testing purpose, you will take one more variable like vVar1 = $(vMaxMonth) - 1 and verify this variable is showing correct value or not. if it is showing correct value then use this new variable.


Not applicable
Author

Variable shows good value, but at the table, the condition about year isn't fulfilled (months are ok) and it shows value from 'else'. When I've got actual value (without minus one) everything's fine.

Not applicable
Author

Actually, I've tried adding it everywhere and it's not working.