Forum Discussion
Calculation Group and SelectedValue
- 1 year ago
Calculation group logic is only applied once per measure, so statements like
VAR _Value = CALCULATE( SELECTEDMEASURE(), CG_TimeIntelligence[Name] = "MTD PY" )won't work.
What you could do is to create a separate calculation group for labels, which would then be able to call the time intelligence calculation items. You could have the calculation item return a numeric value for the variance, which you would then be able to detect in conditional formatting, and use the format string property of the label calculation item to return the formatted string using the exact code you already have in the Label calculation item you posted.
Thank you for your response burakkaragoz
I've tried both methods and none gives me what I want at the end of the day
The issue with the following measure
VAR IsLabel = SELECTEDVALUE(CG_TimeIntelligence[Name]) = "LABEL"
VAR _Variance = CALCULATE(SELECTEDMEASURE(), CG_TimeIntelligence[Name] = "MTD VAR")
RETURN
IF(
IsLabel,
IF(_Variance > 0, 1, IF(_Variance < 0, -1, 0)),
BLANK()
)Is this portion
I don't know why I don't get the CalculationItem Name back when I choose LABEL but some portion of the output.
I've tried it with the CalculationItem[Ordinal] as well and get the same result.
If I can "isolate" that this is my Label if that is true then apply the following rules in terms of the colour that will be based off my Variance which will be numeric for the conditional formatting
Picco ,
You've found the exact issue! SELECTEDVALUE is getting confused because your LABEL calculation item returns formatted text, not just the item name.
Quick fixes to try:
Use the ordinal instead of name:
Label Formatting = VAR IsLabel = SELECTEDVALUE(CG_TimeIntelligence[Ordinal]) = 4 // Check what number LABEL is VAR Variance = CALCULATE(SELECTEDMEASURE(), CG_TimeIntelligence[Name] = "MTD VAR") RETURN IF(IsLabel, IF(Variance > 0, 1, IF(Variance < 0, -1, 0)), BLANK())
Or try MAX instead:
VAR IsLabel = MAX(CG_TimeIntelligence[Name]) = "LABEL"
The ordinal approach usually works better because it's numeric and doesn't get messed up by whatever complex stuff your calculation items are outputting.
What ordinal number does your LABEL item show in the calculation group? Use that number instead of trying to match the text.
This is one of those annoying calculation group quirks where SELECTEDVALUE doesn't behave like you'd expect when the items return complex formatted results.
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
This response was assisted by AI for translation and formatting purposes.