Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

variable on measure

Hi experts

I have 12 measures: "January" , "February", ...."December". These measure come along with an excel file as a key figure model.

In a set expression I would like to filter on one of those 12 measures depending on the Year-Month dimension. Each Year-Month values has 12 measures: Jan up to Dec.  I think we have to define a variable on those measures. Am I right? How would you define this variable?

Thanks, Tom

 

1 Reply
daturpin
Partner - Creator II
Partner - Creator II

If you want to use a variable in an expression, define it in the variables section found at the very bottom of the assets pane, and the definition of the varaible can be blank (set by a script, Vizlib, etc), or itself an expression.

If you want to use a variable in the load editor, just state it by using a statement like LET vmonth = something; (Or use SET if you want the expression to not be calculated until called by $() expansion)

You can also do this directly in the field by using a complex seeded IF statement, like:

If([field] = 'JAN', do january thing, If([field] = 'FEB', do february thing, If([field] = 'MAR', do march thing, else)))

Where the syntax is effectively If(expression, THEN, ELSE)