Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

linoybar
Valued Contributor

Date variable in set analysis

Hi,

I have a max date variable ( vMaxDate=Max(Date) ) and I want to use it in set analysis both for calculations for max date and for previous max date.

The max date works, this is the formula:

Sum({<DateNum={"$(=$(vMaxDate))"}>} Quantity)

But how do I do it for previous date, without creating another variable?

This formula DOES NOT work:

Sum({<DateNum={"$(=$(vMaxDate)-1)"}>} Quantity)

This formula doesn't work either:

Sum({<DateNum={"$(=$(vMaxDate-1))"}>} Quantity)


Where in the formula (if it's possible at all) I have to put -1 so it will work?

***if I do it without using variable, it works, but I want to use  a variable.

Without variable the formula is like this:

Sum({<DateNum={"$(=Max(DateNum-1))"}>} Quantity)

Thanks

1 Solution

Accepted Solutions
rido1421
Contributor III

Re: Date variable in set analysis

Hi Linoy

Have you put an "=" sign in the variable itself?

View solution in original post

6 Replies
rido1421
Contributor III

Re: Date variable in set analysis

Hi Linoy

Have you put an "=" sign in the variable itself?

View solution in original post

linoybar
Valued Contributor

Re: Date variable in set analysis

No. That's why I'm using  it set analysis.

Actually, I added it as you suggested, and it really seems to work now.

I'll make a double check anyway.

Thank you!

rido1421
Contributor III

Re: Date variable in set analysis

When you say the formula is not working is it returning an error or is it giving the same result as max(date) ?

Because your previous date formula will give you the previous day...

linoybar
Valued Contributor

Re: Date variable in set analysis

The same result as a max date...

I'd be glad if you could explain to me why it works this way.

I used the equal sign (=) in set analysis but it wasn't enough, and only when I added it to the variable as you've suggested - it worked.

rido1421
Contributor III

Re: Date variable in set analysis

Im not to sure of the reason, Maybe someone else could explain.

I do believe the answer lies in the type of object you are using the variable in, it may behave differently in a straight table as what it would in a text object.

linoybar
Valued Contributor

Re: Date variable in set analysis

I understand.

Thank you very much!

You've helped me a lot!!!