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

Set Analysis, date variable

Hi all!

I'm trying to make a table with comparison of sales for different periods. User should select one sale period first, and then table would show data for that period and same period from previous year.

Sale periods are in 'YYYY-MM-DD' format with DD = '01'.

I use variables below:
v_sf_MaxPeriod = date(max(saleperiod), 'YYYY-MM-DD')
v_sf_PriorYearDate = date(addyears(max(saleperiod),-1), 'YYYY-MM-DD')

I checked their values in text object, they're ok.

Expression (1) for selected period works correct:
SUM({<saleperiod={"=$(v_sf_MaxPeriod)"}>} sf_fact_count)

Same expression (2) for same period in previous year doesn't work:
SUM({<saleperiod={"=$(v_sf_PriorYearDate )"}>} sf_fact_count)

It returns same result as the previous one. But if I change expression (3) to:
SUM({<saleperiod={"<=$(=$(v_sf_PriorYearDate))>=$(=$(v_sf_PriorYearDate))"}>} sf_fact_count)
it works correct.

Why my expression (2) doesn't work? How to fix it?

Labels (2)
1 Solution

Accepted Solutions
sunny_talwar

Can you try one of these

Sum({<saleperiod = {"$(v_sf_PriorYearDate)"}>} sf_fact_count)

Removed = before $ in the above expression 

Sum({<saleperiod = {"$(=$(v_sf_PriorYearDate))"}>} sf_fact_count)

Added $(...) in the above expression

View solution in original post

2 Replies
sunny_talwar

Can you try one of these

Sum({<saleperiod = {"$(v_sf_PriorYearDate)"}>} sf_fact_count)

Removed = before $ in the above expression 

Sum({<saleperiod = {"$(=$(v_sf_PriorYearDate))"}>} sf_fact_count)

Added $(...) in the above expression

mrbalyaqv
Contributor III
Contributor III
Author

Thanks, Sunny! Second expression works. I was sure, that I've already tried it before, but may be I misspelled somewhere.