Forum Discussion
Conditional colour format on data card
- 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.
HI Anonymous
You can conditionaly format the background of the card.
and the data label of the card.
Yes Anonymous I know you can conditionally format the card, my question is, what measure do I use to say if [current value] is greater than [average value] then 'green' else if [current value] is less than [average value] then 'red' else 'black'
- Anonymous6 years agoNot applicable
hi Anonymous
I would create a measure which return 1 or 0 and -1 for us, and use it to conditionally format.
- edhans6 years agoCommunity Champion
Anonymous - I included a measure that shows 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" )It is not the only way, but a way. Did you download my PBIX file and see how the entire process worked? If it doesn't do what you want, can you be more specific?