The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Our customer asked for a daily scorecard view of a dozen targets. Each row represents a unique target. The screenshot shows the target and the conditional formatting applied. The ID and description columns are not shown. This solution is for conditional formatting of a matrix table by row, by cell.
A SQL Server table was created to store data from the daily batch cycle (INSERT ... SELECT COUNT(1) FROM... statements).
CREATE TABLE dbo.SCORECARD(
SC_DAY DATE,
SC_GOAL_ID INT,
SC_ACTUAL DECIMAL(8,2))
A table was was created in Power BI for ID (1), Description (Widget Tons), Target value (<5000t) for the first three columns of the Matrix table. This was then joined to the SCORECARD table on SC_GOAL_ID and ID.
DAX was used to hardcode the logic to assign 1, 2 or 3 for low, middle, high (Green, Yellow, Red).
The SC_ACTUAL is placed in the Values card for the Matrix. Conditional formatting, background is selected. Format by Rules Based on the DAX formula, _Format. Add an entry for each number 1, 2 & 3 and assign a color.
Finally, use the Icon "Expand all down one level in the heirarchy" to drill into the report to see the finished matrix table.
The user also wanted to see a view of the last day of the week. Added toggle images and actions and filter to show Saturday only view.
HTH, Smitty
HI @Anonymous ,
AFAIK, current power bi not contains row/column index. If you want to conditional formatting row/cell color, you need to add condition to check current row contents and compare with if statement conditions.
BTW, I also try to transform your formula to make it dynamic based on current item and result color string to do color formatting.
_Format = VAR selected = SELECTEDVALUE ( 'BH_SCORECARD'[SC_GOAL_ID] ) VAR _multi = IF ( selected IN { 1, 4 }, 5000, IF ( selected IN { 2, 3 }, 100, IF ( selected IN { 6, 7, 9, 10, 11 }, 20, IF ( selected IN { 8, 11 }, 10, IF ( selected = 5, 25 ) ) ) ) ) VAR _offset = IF ( selected IN { 2, 3 }, 100, 0 ) RETURN IF ( SUM ( 'BH_SCORECARD'[SC_ACTUAL] ) < 1 * _multi + _offset, "Green", IF ( SUM ( 'BH_SCORECARD'[SC_ACTUAL] ) < 2 * _multi + _offset, "Yellow", "Red" ) )
Conditional formatting in tables
Regards,
Xiaoxin Sheng
User | Count |
---|---|
70 | |
64 | |
62 | |
49 | |
28 |
User | Count |
---|---|
117 | |
75 | |
61 | |
54 | |
42 |