Forum Discussion
blaj
Helper I
2 years agoHow do you color code a calculation group using field value?
If you have a calculation group in a matrix that calculates % change for over 20 selected measures, how do you color code % change based on field value without getting a numeric/date error? Any w...
blaj
Helper I
2 years agoI tried this, but it didn't work:
1 Month =
var previousperiod =
CALCULATE(
SELECTEDMEASURE(),
DATETABLE[Month Offset] = -2,
REMOVEFILTERS(DATEPERIOD)
)
var lastperiod =
CALCULATE(
SELECTEDMEASURE(),
DATETABLE[Month Offset] = -1,
REMOVEFILTERS(DATEPERIOD)
)
var calc =
DIVIDE( lastperiod - previousperiod, previousperiod)
var result =
FORMAT(
calc,
SWITCH(
TRUE(),
calc > 0.05, "<span style='color:green'>" & FORMAT(calc, "0.00%") & "</span>",
calc < 0.05, "<span style='color:red'>" & FORMAT(calc, "0.00%") & "</span>",
"<span style='color:yellow'>" & FORMAT(calc, "0.00%") & "</span>"
)
)
RETURN
result
The %Change is the Calcualtion Group itself, not a single measure. There are over 20 DAX measures which I need to calculate 1,3,6,12 month % change over each of them using a calculation group, then color code with field value where > 0.05 is green, < 0.05 is red. Please advise. Thank so much.