Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variabilize set modifier

Hi,

I have defined as Time Dimensions as below:

Date defined as vTimeDim = 1, 

Week defined as vTimeDim = 2,

Month defined as vTimeDim = 3,

Year defined as vTimeDim = 4. vTimeDim is the action given to the text Objects so that user can toggle between the different time dimensions.

And I have expression as

pick(vTimeDim,

sum({<Link_Date={'$(vToDate)'}>}Applications,

sum({<Link_Date={">=$(=DATE(weekstart(vToDate)))<=$(vToDate)"}>}Applications,

sum({<Link_Date={">=$(=DATE(monthstart(vToDate)))<=$(vToDate)"}>}Applications,

sum({<Link_Date={">=$(=DATE(yearstart(vToDate)))<=$(vToDate)"}>}Applications)

Is there a way to variablize the date modifier, so that I can write just one expression.

Something like =sum({<$(vTimeSetExp)>}Applications.

I'm not sure how to put the date modifiers into vTimeSetExp

Thanks for all the help in advance.

4 Replies
sunny_talwar

How about this:

Sum({<Link_Date = {"$(=Pick(vTimeDim, '$(vToDate)', >=$(=Date(WeekStart(vToDate)))<=$(vToDate), >=$(=Date(MonthStart(vToDate)))<=$(vToDate), >=$(=Date(YearStart(vToDate)))<=$(vToDate))"}>}Applications)

Not applicable
Author

Sunny, Appreciate your quick and prompt response.

Is there a way to completely get rid of Link_Date = {"$(=Pick(vTimeDim, '$(vToDate)', >=$(=Date(WeekStart(vToDate)))<=$(vToDate),>=$(=Date(MonthStart(vToDate)))<=$(vToDate), >=$(=Date(YearStart(vToDate)))<=$(vToDate))"} this par.

I mean can we replace it with a variable. Because I have about 50 metrics and I'll have to write this part for all of them right.

sunny_talwar

See if you like the approach in the attached qvw file. I can provide another one based on a variable, but this one uses a technique from an inline load in the script.

Capture.PNG

Anonymous
Not applicable
Author

Hi aditya,

You can use variable functions to create a variable Set Analysis. See this post:

https://community.qlikview.com/thread/18030

For example:

Your variable: ='{<Link_Date={">=$(=DATE('&$1&'(vToDate)))<=$(vToDate)"}>}'

Your expression: sum($(YourVarName('weekstart'))Applications)

Regards!!