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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

variables in Set analysis

Hi I am using the below expression and its not working...can anybody tell me what's wrong with that

sum({$<Status_FA={'A'},Month_No={$(var_month)}>}Revenue)-sum({$<Status_FA={'A'},Month_No={$(var_month)}>}Discount)

where var_month is the variable which is assigned the value as field Month_No

Month_No is in date format.

Please help me

11 Replies
sudeepkm
Specialist III
Specialist III

try "" around the variable name

"$(var_month)"

maxgro
MVP
MVP

try debugging your set analysis expression (thanks to John Witherspoon)

"
For debugging set analysis, make a chart that has your set analysis expression as the first chart expression, but do NOT label the expression, and do NOT supply a caption for the chart.  The caption and column heading will then show your expression.  One of them (I forget which) shows the expression just like you wrote it.  One of them shows it after the dollar sign substitution has taken place.  Comparing the two will very often let you know what's going wrong, or at least WHERE it is going wrong.

"

Not applicable
Author

Thanks Sudeep

using " " around $(var_month) is making it as string and again it's not working

jagan
Partner - Champion III
Partner - Champion III

Hi Anuj,

I think the issue is because of formatting.  What is the format of var_month and Month_No is both values are in same format?  If not then convert to the same format.

If your Month_No column has 1 to 12 and var_month has one value of 1 to 12, then this works.

sum({$<Status_FA={'A'},Month_No={$(var_month)}>}Revenue)-sum({$<Status_FA={'A'},Month_No={$(var_month)}>}Discount)

Regards,

Jagan.

Not applicable
Author

try $(=var_month)

regards,

MT

Not applicable
Author

Hi Jagan,

Yes both Month_No and var_month are in same format which is date.

jagan
Partner - Champion III
Partner - Champion III

HI,

Try this

sum({$<Status_FA={'A'},Month_No={'$(=var_month)'}>}Revenue)-sum({$<Status_FA={'A'},Month_No={'$(=var_month)'}>}Discount)


Regards,

Jagan.

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

How you created the field Month_No i.e., using Month(DateField)?

And how you assigned value to the variable using month function or something els?

Not applicable
Author

Month_No is just the name of the field having values as Date type.

for assigning value to the variable go to Settings->Document Properties->Variables

and there you can assign any constant value or field value.