Forum Discussion
Anonymous
6 years agoNot applicable
Conditional colour format on data card
Hi there I have two data cards - one with an average pass ratio, and the other with the pass ratio which changes when you select different slicers. So you can compare the pass ratio alongside the...
- 6 years ago
Hi Anonymous, this is a multistep process.
- Compute a measure that returns your color selections. I used this:
Vs Average = VAR varCurrentValue = SELECTEDVALUE('Table'[Value],0) VAR varAverage = [Average Value] RETURN SWITCH( TRUE(), varCurrentValue > varAverage, "Green", varCurrentValue = varAverage, "Black", varCurrentValue < varAverage, "Red" )-
- So if the current selected value (I used a slicer to select a value) is greater than the Average Value measure, return Green, if equal, black, if below, red. The average value measure is:
Average Value = CALCULATE( AVERAGE('Table'[Value]), REMOVEFILTERS('Table'[Category]) )- Then on the original card, select the label property and change the color from what is probably black to use the fx button conditional format:
-
- Then select the Field Value setting, and select the measure you used - Vs Average in my case.
-
-
You can see my PBIX here if you want to play with it a bit. You can get rid of my green/red/black text and use hex codes as long as they are in the format "#000000" with the # sign to tweak those colors.
edhans
6 years agoCommunity Champion
Hi Anonymous, this is a multistep process.
- Compute a measure that returns your color selections. I used this:
Vs Average =
VAR varCurrentValue = SELECTEDVALUE('Table'[Value],0)
VAR varAverage = [Average Value]
RETURN
SWITCH(
TRUE(),
varCurrentValue > varAverage, "Green",
varCurrentValue = varAverage, "Black",
varCurrentValue < varAverage, "Red"
)
-
- So if the current selected value (I used a slicer to select a value) is greater than the Average Value measure, return Green, if equal, black, if below, red. The average value measure is:
Average Value =
CALCULATE(
AVERAGE('Table'[Value]),
REMOVEFILTERS('Table'[Category])
)
- Then on the original card, select the label property and change the color from what is probably black to use the fx button conditional format:
-
- Then select the Field Value setting, and select the measure you used - Vs Average in my case.
-
-
You can see my PBIX here if you want to play with it a bit. You can get rid of my green/red/black text and use hex codes as long as they are in the format "#000000" with the # sign to tweak those colors.