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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic Measure on GetCurrentSelections

Hi All,

I am looking to have a dynamic measure in a chart based on a current selection on a dimension.

In my example, I want it to give me measure (a) if I select the dimension 'month', and if 'month' is not selected, give me measure (b). My expression works fine, but there is a massive performance overhead.

IF(GetCurrentSelections(), = 'month',

  sum({1 <cytd_flag = {1}, [currency to]=>} [quantity activities]), /* Measure (a)*/

    sum({<cytd_flag = {1}, [currency to]=>} [quantity calls]))  /* Measure (b)*/

Any suggestions to achieve the same result?


Thanks in advance

Labels (1)
1 Solution

Accepted Solutions
rubenmarin
MVP
MVP

Hi Christopher, if you want to check any values directly selected on a field you can try with GetSelectedCount():

GetSelectedCount(Month) // If no value is selected in the field returns 0, wich is equal to False.

if (GetSelectedCount(Month),

     sum({<cytd_flag = {1}, [currency to]=>} [quantity activities]),

          sum({ 1 <cytd_flag = {1}, [currency to]=>} [quantity calls])  

     )

Note that it will also return true when there is more than one value selected

View solution in original post

3 Replies
rubenmarin
MVP
MVP

Hi Christopher, maybe using the field instead of the general 'GetCurrentSelction()':

IF(DimensionFieldName = 'month',

Also you can try if the conditional expressions gives better performance, create both expressions and opposed conditions like:

- For measure (a):

DimensionFieldName = 'month'


-For measure (b)

  DimensionFieldName <> 'month'


And if you're using dimension groups check this post on how to detect the actual dimension: Did you know..? Cyclic Group

Not applicable
Author

Hi Ruben,

If I use the fieldname, I will then be getting the values within the field. I.e. [month] = 'Jan, Feb, Mar'.

However, with a bit of tweaking, I've used the following and it works much better.

if ( match([month],'Jan',' Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),

     sum({<cytd_flag = {1}, [currency to]=>} [quantity activities]),

          sum({ 1 <cytd_flag = {1}, [currency to]=>} [quantity calls])    

     )

Thanks

rubenmarin
MVP
MVP

Hi Christopher, if you want to check any values directly selected on a field you can try with GetSelectedCount():

GetSelectedCount(Month) // If no value is selected in the field returns 0, wich is equal to False.

if (GetSelectedCount(Month),

     sum({<cytd_flag = {1}, [currency to]=>} [quantity activities]),

          sum({ 1 <cytd_flag = {1}, [currency to]=>} [quantity calls])  

     )

Note that it will also return true when there is more than one value selected