Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hello,
I am trying to apply conditional formatting to the below matrix. I want to apply green when the percentage goes up and red when the percentage goes down. I do not, however, want the color to continue until the percentage changes.
I am using two unconnected tables to produce the matrix. One is a date table with a single column of dates from 1/1/2020 to 3/1/2022. The increment on the dates is one month. The second is a data table with the following data. (Please note instead of writing out the Opportunity ID's in the table below for the matrix above I substituted A,B,C,D, and dummy data).
Below is the measure used in the matrix and I am using the date field as the matrix column:
Solved! Go to Solution.
Hi @amccallum ,
I suggest you to try this code to create a color measure.
Color =
VAR _Change_Date =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER (
ALL ( 'Table' ),
'Table'[Value] <> SUM ( 'Table'[Value] )
&& 'Table'[Category] = MAX ( 'Table'[Category] )
&& 'Table'[Date] < MAX ( 'Table'[Date] )
)
)
VAR _Change_Value =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Category] = MAX ( 'Table'[Category] )
&& 'Table'[Date] = _Change_Date
)
)
RETURN
IF (
ISBLANK ( _Change_Value ),
BLANK (),
IF ( SUM ( 'Table'[Value] ) > _Change_Value, "Green", "Red" )
)
Then add this measure into conditional formatting in matrix visual.
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @amccallum ,
I suggest you to try this code to create a color measure.
Color =
VAR _Change_Date =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER (
ALL ( 'Table' ),
'Table'[Value] <> SUM ( 'Table'[Value] )
&& 'Table'[Category] = MAX ( 'Table'[Category] )
&& 'Table'[Date] < MAX ( 'Table'[Date] )
)
)
VAR _Change_Value =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Category] = MAX ( 'Table'[Category] )
&& 'Table'[Date] = _Change_Date
)
)
RETURN
IF (
ISBLANK ( _Change_Value ),
BLANK (),
IF ( SUM ( 'Table'[Value] ) > _Change_Value, "Green", "Red" )
)
Then add this measure into conditional formatting in matrix visual.
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you this works.
@amccallum , Using Date table and TI, you can get
This Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(sum('Table'[Qty]), previousday('Date'[Date]))
diff =[This Day] - [Last Day]
You can create a color measure and use that in conditional formatting using field value option
color =
var _change =[This Day]-[Last Day]
return
SWITCH (
TRUE(),
_change > 0, "green",
_change = 0, "blue",
_change < 0, "red"
)
Thank you for your reply. I have applied the measures you added, but this is not working. For some reason the measure This Day and Last Day are only picking up the first day in the matrix and using that for comparison. Please see picture below.
I think this is caused by the date table being disconnected from the data table which is needed for the spread of the percentages across the dates. When I connect the tables the conditional formatting works fine, but the spread disappears. Do you know how to do the conditional formatting without connecting the tables?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 57 | |
| 33 | |
| 33 | |
| 18 | |
| 16 |
| User | Count |
|---|---|
| 66 | |
| 64 | |
| 44 | |
| 30 | |
| 29 |