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

Using a variable storing Date in Set Analysis

Hi!

I´m having a problem....

I´ve got several Date fields in my Data and I need to be able to select one of those dates based in a variable that is storing another date.

Date fields:

     -Data;

     -dataVenda.

Variable:

     -vSetData =dataVenda

This variable captures date from "dataVenda". Used in a Text Box it returns the Date just fine. Text box, i´m using =vSetData

Now my problem is that I cannot use vSetData in Set Analysis... I´ve tried several expressions, and none of them worked.

My expression is plain simple, just a sum with set analysis:

Sum({$<Data={???????}>} Afield)

If I use, for instance,  Sum({$<Data={'26-09-2012'}>} Afield) it works fine.

I´ve used $(vSetData), =vSetData, some expressions with '=$(=vSetData)', I don´t know how many expressions have I tried... 😕

I need to use Data, because is the one directly related to the field I need to Sum.... I cannot use dataVenda directly in here...

Best Regards,

Bruno Silva.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

vSetData =Date(dataVenda)


Sum({$<Data={'$(vSetData )'}>} Afield)

View solution in original post

18 Replies
MK_QSL
MVP
MVP

vSetData =Date(dataVenda)


Sum({$<Data={'$(vSetData )'}>} Afield)

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Does the text box with =vSetData return anything when you clear all selections? If the answer is no, then you cannot use vSetData in the way you are attempting. If you need to use all the possible values (after making selections) of dataVenda, then you could try:

Sum(<Data = P(dataVenda)>} Afield)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi Jonathan!

I wasn´t looking for All Possible values... But thanks anyway!!! Manish gave the right answer... I knew that it was a minor detail...

Thank you both!!!

Best Regards,

Bruno Silva.

Not applicable
Author

Why doesn´t this work the same way when I create a new variable to Last Year same date:

vSetDataLY =AddMonths( dataVenda, -12)

And then use it as I did before?

Sum({$<Data={'$(vSetDataLY )'}>} Afield)


This doesn´t work... But in a Textbox, It does return the correct date with =vSetDataLY


Best regards,

Bruno Silva.

MK_QSL
MVP
MVP

Try

vSetDataLY =Date(AddMonths( dataVenda, -12))

Not applicable
Author

Didn´t work....

As the Text Box returns correct date, I´m guessing that is something about how the variable is implemented in Set Analysis... But again, tried several ways to call the vSetDataLY in Data=, but any results so far...

Thanks,

BS.

MK_QSL
MVP
MVP

Try

vSetDataLY = Date(AddYears(dataVenda,-1),'DD-MM-YYYY')

Not applicable
Author

It doesn´t work either...

But the Text Box is still returning the right date...

MK_QSL
MVP
MVP

what is the format of Data?