Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
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
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