Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Piece of set analysis in a variable ?

Hello everyone,

In an application, I often use a piece of code in a set analysis which is quite long. is there a way to store it in kind of a variable so I don't have to write it each time ?

Thank you

Laura

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Yes, that's a very good idea. Here's an example:

original:

expression: sum({<FieldA={'Something'},FieldB={'>100'}>+<FieldC={'=sum(Sales)<1000'}>}Sales)

using a variable:

variable: vSetMod: {<FieldA={'Something'},FieldB={'>100'}>+<FieldC={'=sum(Sales)<1000'}>}

expression: sum( $(vSetMod) Sales)

You can of course also store parts the complete set modifier into different variables and combine those in the expression or in yet another variable. Variables can even take parameters:

vSetMod:  {<FieldA={$1}>)

sum( $(vSetmod('Something')) Sales)


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

Yes, that's a very good idea. Here's an example:

original:

expression: sum({<FieldA={'Something'},FieldB={'>100'}>+<FieldC={'=sum(Sales)<1000'}>}Sales)

using a variable:

variable: vSetMod: {<FieldA={'Something'},FieldB={'>100'}>+<FieldC={'=sum(Sales)<1000'}>}

expression: sum( $(vSetMod) Sales)

You can of course also store parts the complete set modifier into different variables and combine those in the expression or in yet another variable. Variables can even take parameters:

vSetMod:  {<FieldA={$1}>)

sum( $(vSetmod('Something')) Sales)


talk is cheap, supply exceeds demand
datanibbler
Champion
Champion

Hi Laura,

in principle, that is possible, no problem. You can use variables in a set_analysis - I have tried only with "simple" numeric values which don't require that expansion thingy, but I guess it should be possible with those, too.

HTH

Best regards,

DataNibbler

Not applicable
Author

thank you Gysbert

Have a good day !