Forum Discussion
Background color for Matrix visual for Average values
Hi All,
I am trying to give background color in Matrix visuals based on Average Values.
As you see in the attached screenshot I have "Sites" column in Filter.
I have Category, Metrics column followed by their respective values for each month.
Difference metrics will have different color thresholds.
I would like to write a formula in Dax which achieves the following:
Metrics A should show its relevant BG colors - if it is greater than or equal to 95 then Green BG
if is less than 90 then red else Yellow
Metrics B should show its relevant BG - if it is greater than or equal to 90 then Green BG
if is less than 85 then red else Yellow
The main thing is if we do multi selection in Filter, i.e., if we select both the sites in sites filter then the matrix visuals will show average values and BG color has to be changed accordingly with respect to the "Average"Values.
What would be the DAX?
Thank you in Advance.
Regards,
Prakash M
Hello !
Thank you for posting on Fabric community.
You can use your existing KPI measure in place of value if it has a different name
Avg Value (across Sites) = AVERAGEX( VALUES('Sites'[Site]), CALCULATE([Value]) )Then you switch the background color depending on the thresholds :
BG Color := VAR m = SELECTEDVALUE('Table'[Metrics]) VAR v = [Avg Value (across Sites)] RETURN SWITCH( TRUE(), m = "Metrics A" && v >= 0.95, "#118D57", -- green m = "Metrics A" && v < 0.90, "#D14343", -- red m = "Metrics B" && v >= 0.90, "#118D57", -- green m = "Metrics B" && v < 0.85, "#D14343", -- red "#F7B500" -- yellow )
4 Replies
- AmiraBedhSuper User
Hello !
Thank you for posting on Fabric community.
You can use your existing KPI measure in place of value if it has a different name
Avg Value (across Sites) = AVERAGEX( VALUES('Sites'[Site]), CALCULATE([Value]) )Then you switch the background color depending on the thresholds :
BG Color := VAR m = SELECTEDVALUE('Table'[Metrics]) VAR v = [Avg Value (across Sites)] RETURN SWITCH( TRUE(), m = "Metrics A" && v >= 0.95, "#118D57", -- green m = "Metrics A" && v < 0.90, "#D14343", -- red m = "Metrics B" && v >= 0.90, "#118D57", -- green m = "Metrics B" && v < 0.85, "#D14343", -- red "#F7B500" -- yellow ) - srlabheSuper User
Hi Create a measure like below
var_MetricsA= if (MetricsA>=95,0,
if(MetricsA<=90,1,2))
Then use this varMetricsA in conditional formatting with Rules to setup on varMetricsA and add the conditions there like
if varMetrics=0 then select any Green color from pallet
if varMetrics=1 then select any red color from pallet
if varMetrics>1 then yellow
Hope it helps
- mprakaAdvocate II
- AnonymousNot applicable