Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variable in set analysis

Hi All,

I have a variable:

Date(AddMonths(min({<[Fcst Version]={"$(=Maxstring(Fcst_Num))"}>}[Fcst Month]),-1),'MMM-YY')

This determines the Minimum month of the maxstring of the fcst Version.

Now I have a set analysis that I need to include the variable.

Sum({<MonthYear={insert variable here}>}Fcst Qty)

How can I apply that?

My current set analysis does not work:

Sum({<MonthYear={$vMinFcstMonth}>} Fcst Qty)

Thanks

4 Replies
sundarakumar
Specialist II
Specialist II

try using

sum({<[Month Year]={'$(=vMinFcstMonth)'}>}[Fcst Qty])

pls check first if the variable is returning the required value with a text box

-Sundar

sundarakumar
Specialist II
Specialist II

if this doesn't work,

put an equal sign before the variable in variable overview

check if it is returning the year month intended by putting it in a text box

if it is ok

use expression as

sum({<[Month Year]={$(vMinFcstMonth)}>}[Fcst Qty])

this should work.

-Sudnar

Not applicable
Author

Yes this one works.. My other question is how to create a comparison between a variable in a set analysis.

ex: vMinMonth = Apr-14

sum({<[Month Year]={">=$(=Min([Fcst Month]))<=$($(vMinMonth))"}>}[Fcst Qty])

// what I want sum({<[Month Year]=Mar-14<=Apr-14>}

on my part this does not produce the result I wanted

sundarakumar
Specialist II
Specialist II

I would prefer to change the data to its number format when u want to implement such time ranges.

Because interpreting the number is faster and easier. though this can be done with the time fields too.

num(date) would return the number format of the date. have this as a field in ur back end. use this new field in ur set analysis. for eg if u want to see the data of last one month u would use it as

sum({<date_num={>vlastmonthdate,<vtoday}>}sales)

create variable like vtoday=num(today()) and vlastmonthdate=num(today()-30).

Like this u can create what ever time range u wish to filter.

Pls specify the business rule of what time range u need so that we can help u in the same.

Hope this helps.

Regards,

Sundar