Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello All,
What I want to Achieve:
I have a table where I consolidate all KPIs inputs from stakeholders to track their performance on monthly basis against set targets.
I am pretty comfortable with Power BI and producing visuals, applying custom color coding but for matrix table I am not getting the right formulas on how to enforce color coding measure on such data structure and how to enforce format per row as well since both ACT and TGT are on same column. I am specific about the visual use since its a management request 😀
I would apprciate your advise, direction and help in DAX if needed to be able to produce the desired output. Thanks all for your support in advance
Below is desired result I wish to achieve:
Same format applies to the rest of the months Feb-Dec
Facts about the Sample Data Table:
Sample Data Table
Solved! Go to Solution.
Hi , @sas5610
Thanks for your sample data first~
According to your description, you want to create a Matrix visual as your image.
Here are the steps you can refer to :
(1)My test data is the same as yours.
(2)We can create a sort column in Power Query to sort out [Type] Column:
(3)Then we can apply the data to desktop and we need to create two measures:
Measure = var _uon = MAX('Table'[UOM])
return
SWITCH(_uon,
"$/kg" , FORMAT(SUM('Table'[Value]) , "0.00"),
"%" , FORMAT(SUM('Table'[Value]) , "0%"),
"$k" , FORMAT(SUM('Table'[Value]) , "0.00"),
"PPM" , FORMAT(SUM('Table'[Value]) , "0"))
Color = var _type = MAX('Table'[Type])
var _derection=MAX('Table'[KPI Direction])
var _tgt = CALCULATE( SUM('Table'[Value]) , 'Table'[Type] = "TGT",ALLEXCEPT('Table','Table'[KPI],'Table'[UOM]))
return
IF(_type="ACT",IF(OR(_derection = "Increase" && SUM('Table'[Value]) > _tgt , _derection = "Decrease" && SUM('Table'[Value]) <= _tgt ) , "green" ,"red"))
(4)Then we can put the fields we need on the visual and we can configure some options we need , like this:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks for your support Aniya, you saved me a lot of time. Exactly what I wanted and easy to follow solution!! I have a quesiton on the color measure for clarificationn only. Why do you used max function as variable and what it does produce as output?
Hi , @sas5610
Thanks for your sample data first~
According to your description, you want to create a Matrix visual as your image.
Here are the steps you can refer to :
(1)My test data is the same as yours.
(2)We can create a sort column in Power Query to sort out [Type] Column:
(3)Then we can apply the data to desktop and we need to create two measures:
Measure = var _uon = MAX('Table'[UOM])
return
SWITCH(_uon,
"$/kg" , FORMAT(SUM('Table'[Value]) , "0.00"),
"%" , FORMAT(SUM('Table'[Value]) , "0%"),
"$k" , FORMAT(SUM('Table'[Value]) , "0.00"),
"PPM" , FORMAT(SUM('Table'[Value]) , "0"))
Color = var _type = MAX('Table'[Type])
var _derection=MAX('Table'[KPI Direction])
var _tgt = CALCULATE( SUM('Table'[Value]) , 'Table'[Type] = "TGT",ALLEXCEPT('Table','Table'[KPI],'Table'[UOM]))
return
IF(_type="ACT",IF(OR(_derection = "Increase" && SUM('Table'[Value]) > _tgt , _derection = "Decrease" && SUM('Table'[Value]) <= _tgt ) , "green" ,"red"))
(4)Then we can put the fields we need on the visual and we can configure some options we need , like this:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
58 | |
56 | |
56 | |
38 | |
29 |
User | Count |
---|---|
75 | |
62 | |
45 | |
40 | |
39 |