Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Uploads getting stuck in the virus scanner. We are investigating.
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted

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
Highlighted

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

Highlighted
Contributor III
Contributor III

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