Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi, I'm having trouble coming up with the right measure to apply conditional formatting on this matrix table. I understand the process of using a measure as the values to base a conditional formatting on, but I'm having trouble getting it to return the right results. I am using a matrix with 3 fields for the rows, Industry > Sales Grouping > Account. For the columns, I am using the Service Group field, and for the values Average Revenue. For each cell, I'd like to have the following logic:
I'm not sure if it's possible to extend this logic to higher hierarchy levels like Sales Grouping, but I would at least like it at the lowest level, Account. Let me know if more clarification is needed. Thanks!
Hi @andre2x
Thanks for the clarification, I’ve adjusted the logic and it’s now doing exactly what you described:
Use bellow measure in Matrix table.
Avg Revenue Display or Fallback =
VAR CurrentAvg = [Avg Revenue]
VAR IsBlankRevenue = ISBLANK(CurrentAvg) || CurrentAvg = 0
VAR SelectedSalesGroup = SELECTEDVALUE('AvgRevenueMatrix'[Sales Grouping])
VAR SelectedServiceGroup = SELECTEDVALUE('AvgRevenueMatrix'[Service Group])
VAR FallbackSubtotal = CALCULATE([Avg Revenue],
REMOVEFILTERS('AvgRevenueMatrix'[Account]),'AvgRevenueMatrix'[Sales Grouping] = SelectedSalesGroup, 'AvgRevenueMatrix'[Service Group] = SelectedServiceGroup)
RETURN
IF(IsBlankRevenue, FallbackSubtotal, CurrentAvg)
After dragging Avg Revenue Display or Fallback measure in Matrix visual, use Avg Revenue Color Category in conditional formatting.
Avg Revenue Color Category =
VAR CurrentAvg = [Avg Revenue]
VAR IsBlankRevenue = ISBLANK(CurrentAvg) || CurrentAvg = 0
VAR SelectedSalesGroup = SELECTEDVALUE('YourTable'[Sales Grouping])
VAR SelectedServiceGroup = SELECTEDVALUE('YourTable'[Service Group])
VAR FallbackSubtotal = CALCULATE([Avg Revenue], REMOVEFILTERS('YourTable'[Account]),
'YourTable'[Sales Grouping] = SelectedSalesGroup,'YourTable'[Service Group] = SelectedServiceGroup)
RETURN
IF(IsBlankRevenue, SWITCH(TRUE(), FallbackSubtotal < 5000, "Red", FallbackSubtotal < 15000, "Yellow","Green"),BLANK() // Don't format if actual value exists)
Attached screenshot shows the result: blank cells are now visually meaningful without overriding valid data.
Let me know if you’d like to extend this logic to even higher levels like Industry or dynamic color thresholds.
________________________________________________________________________________________________________________________
If this response helps, consider marking it as “Accept as solution” and giving a “kudos” to assist other community members.
Reagrds,
Akhil.
Hi @andre2x
I’ve actually worked through this exact scenario and got a working solution that does what you’re looking for.
You wanted each blank ($0) cell in the matrix to:
To achieve this, I created a DAX measure that,
Avg Revenue Conditional Format =
VAR CurrentAvg = [Avg Revenue]
VAR IsBlankRevenue = ISBLANK(CurrentAvg) || CurrentAvg = 0
VAR SelectedSalesGroup = SELECTEDVALUE('YourTable'[Sales Grouping])
VAR SelectedServiceGroup = SELECTEDVALUE('YourTable'[Service Group])
VAR FallbackSubtotal =CALCULATE([Avg Revenue],REMOVEFILTERS('YourTable'[Account]),
'YourTable'[Sales Grouping] = SelectedSalesGroup, 'YourTable'[Service Group] = SelectedServiceGroup)
RETURN
IF(IsBlankRevenue, FallbackSubtotal, CurrentAvg)
(Just replace 'YourTable' with your table name and [Avg Revenue] with your existing measure.)
Now use this measure applying in conditional formatting.Even the blank cells are now shaded using their parent subtotal’s value, giving consistent, meaningful color context across the entire matrix.
Attaching snip for your refferance.
________________________________________________________________________________________________________________________
If this response helps, consider marking it as “Accept as solution” and giving a “kudos” to assist other community members.
Reagrds,
Akhil.
Thanks Akhil, I'm on the right track with this but I'm more looking to get the parent averages to display when the Account Avg Revenue is blank for a service group, then color code from there. So cells with Avg Revenue in them will not be color coded.
User | Count |
---|---|
85 | |
77 | |
68 | |
49 | |
41 |
User | Count |
---|---|
111 | |
56 | |
50 | |
42 | |
40 |