Forum Discussion
Problem with Cell Elements Formatting
- 8 months ago
Hi MJG2112 , Thank you for reaching out to the Microsoft Community Forum.
Make sure the table visual includes a unique A key so the measure can evaluate per row. Then add this test measure to the visual, you should see 1 or 0 for each A row:
HasBFlag =
IF( CALCULATE( COUNTROWS( TableB ) ) > 0, 1, 0 )
Apply conditional formatting. Conditional formatting -> Icons (or Background) -> Format style = Rules -> What field should we base this on? = HasBFlag -> Summarization = First. Create two rules: 1 => green icon, 0 => red icon. Don’t return BLANK(), use 0 for missing-B. If A->B filtering is unreliable, use the explicit key variant that matches A’s key to B’s key.
If the test measure still shows the same value for every row, paste the exact DAX you used and a screenshot of the table with the test measure visible and anything you may feel relevant to the issue.
amitchandak I think I might not be explaining very well. I already have rule based formatting as you can see. It's based on the column being formatted, which is from Table A and is not blank or null. It has 'Yes' and 'No' values. The problem is it's not being applied to those rows that don't have a record in Table B. I would expect the Level OK column on the second row and bottom 2 rows in the other screenshoot to have the icon displayed.
Hi MJG2112 , Thank you for reaching out to the Microsoft Community Forum.
amitchandak is right that you can detect the presence of a related row in Table B with an aggregate like MAX(TableB[Outcome]) and that conditional formatting should be driven by a measure when the visual is built from Table A but the row exists or not information lives in Table B.
When a row from A has no match in B, the formatting engine ends up evaluating the rule against an empty related context. Even though Level OK itself contains Yes/No, the rule engine still gets a blank formatting value and Power BI treats that as don’t apply any icon. That’s why those A only rows don’t show your green/red icons. The fix is to base the formatting on a measure that always returns a concrete value. For example:
LevelOK_IconFlag =
IF( NOT ISBLANK( MAX( TableB[Outcome] ) ), 1, 0 )
or a colour version if you prefer field value formatting. Point your icon rules at this measure instead of the raw Level OK column and map 1 and 0 to the icons you want. Because the measure returns a definite value for both cases, the icons will show even when Show items with no data is bringing in rows that have no B record.