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

How to use variable in Set Analysis

Hi All,

I would like to use Variable in Set Analysis:

vStartDate='2015-1-1'

vEndDate='2015-2-1'

How to use it in pivot table expression sum({<YearMonth={'>=vStartDate<vEndDate'}>}revenue) ?

Thanks.

1 Solution

Accepted Solutions
MayilVahanan

Hi

Try like this

=Sum({<YearMonth= {'>=$(vStartDate)<=$(vEndDate)'}>}revenue)

Hope YearMonth filed has same format as in Variables (i.e. YYYY-M-D) If not , please  mention the format for YearMonth Field

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

8 Replies
tresesco
MVP
MVP

The field you are comparing with (YearMonth) data format has to match with the variable content. That is what you have to make sure. How does your YearMonth data look like? Which function have you used in the script to create it?

MayilVahanan

Hi

Try like this

=Sum({<YearMonth= {'>=$(vStartDate)<=$(vEndDate)'}>}revenue)

Hope YearMonth filed has same format as in Variables (i.e. YYYY-M-D) If not , please  mention the format for YearMonth Field

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
prieper
Master II
Master II

In order not to get trapped by different formats, it makes sense to convert the dates to numbers and the make a numerical comparison.

HTH Peter

Not applicable
Author

Hi tresesco,

Thanks for your prompt reply, My YearMonth format is the same as the variable like 'YYYY-MM-DD'

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

sum({<YearMonth={'>=$(=vStartDate)<$(=vEndDate)'}>}revenue)


Note: YearMonth date values and variable values should be in same format.


Regards,

jagan.

mayankraoka
Specialist
Specialist

Hi ,

You can use this:

sum({<YearMonth={'>=$(=$(vStartDate))<$(=$(vEndDate))'}>}revenue)


Regards,

Mayank

tresesco
MVP
MVP

Try like:

sum({<YearMonth={'>=$(vStartDate)<$(vEndDate)'}>}revenue)

Peter_Cammaert
Partner - Champion III
Partner - Champion III

The basic rule - that you can make out from tres' suggestion and all identical copies down below (?) - is that in a set modifier you specify either exact field values to use, or a "search" string (like when you start typing in a list box). A search string will not handle variables. But in a set modifier it will handle $-sign substitution to translate a variable reference into its actual content.