Qlik Community

Qlik Sense App Development

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

mrbalyaqv
New Contributor II

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

Re: Set Analysis, date variable

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

2 Replies

Re: Set Analysis, date variable

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
New Contributor II

Re: Set Analysis, date variable

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