Forum Discussion
Power BI Chart - Matrix Chart
Hi All,
Please help me creating DAX measures to showcase the below request.
- From a product cost perspective, where have we increased cost year over year (and to what extent)
- For products that we have increased selling cost, how much of the sales growth year over year has been a result of cost increases vs quantity increases?
Create a matrix chart to show the year over year comparison for above two questions
Here is a rough data for reference.
| Product | Date | Quantity | Cost |
| USA | 2025-02-24 | 974 | 97.67 |
| Brazil | 2023-11-30 | 257 | 99.44 |
| Germany | 2024-12-24 | 892 | 46.83 |
| India | 2024-04-05 | 774 | 86.16 |
| USA | 2024-11-21 | 619 | 73.81 |
| USA | 2023-10-15 | 527 | 13.08 |
| India | 2024-06-28 | 999 | 20.5 |
| USA | 2025-01-17 | 539 | 76.46 |
| India | 2025-01-01 | 395 | 43.27 |
| USA | 2024-10-27 | 331 | 97.85 |
| Japan | 2025-02-09 | 198 | 62.77 |
| India | 2024-08-11 | 745 | 53.3 |
| Germany | 2025-03-13 | 861 | 51.2 |
| USA | 2024-06-01 | 772 | 35.73 |
| Germany | 2024-10-26 | 364 | 55.37 |
| Germany | 2023-10-22 | 492 | 50.34 |
| Brazil | 2025-03-28 | 622 | 46.99 |
| India | 2024-12-07 | 418 | 28.54 |
| Brazil | 2025-03-07 | 539 | 58.89 |
| India | 2023-07-26 | 707 | 89.49 |
Please attach the power bi file that you worked on to apply the DAX measures with my column names. Thanks a ton!
Hi royalty123,
Thank you for reaching out to the Microsoft fabric community forum. Thank you lbendlin, danextian, for your inputs on this issue.
After thoroughly reviewing the details you provided, I was able to reproduce the scenario, and it worked on my end. I have used it as sample data on my end and successfully implemented it.
Date Table Dax:
CalendarTable = ADDCOLUMNS(
CALENDAR(MIN(Data[Date]), MAX(Data[Date])),
"Year", YEAR([Date]),
"Month", FORMAT([Date], "MMM")
)
Previous Year’s Cost Measure:Prev_Year_Cost = CALCULATE(SUM(Data[Cost]), SAMEPERIODLASTYEAR(CalendarTable[Date]))
Cost Increase YoY Measure:
Sales Growth from Cost Increase Measure:Cost_Change_YoY = SUM(Data[Cost]) - [Prev_Year_Cost]
Previous Year’s Quantity Measure:
Prev_Year_Qty = CALCULATE(SUM(Data[Quantity]), SAMEPERIODLASTYEAR(CalendarTable[Date]))
Sales_Growth_from_Cost = [Cost_Change_YoY] * [Prev_Year_Qty]Sales Growth from Quantity Increase Measure:
Sales_Growth_from_Qty = SUMX(Data, Data[Cost] * (Data[Quantity] - Data[Prev_Year_Qty]))
I am also including .pbix file for your better understanding, please have a look into it:
I hope this could resolve your issue, if you need any further assistance, feel free to reach out. If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
7 Replies
- danextianSuper User
You seem to have forgotten the Power BI file. Please post the link to file stored in the cloud. Only superusers, MVPs and admins can attach files.
- royalty123Regular Visitor
Hi danextian : I don't have any power bi file. I just had an excel file. I shared the table along with my question. Thank you!
- lbendlinSuper User
No need for measures. You can visualize this without code.
- v-kpoloju-msftCommunity Support
Hi royalty123,
Thank you for reaching out to the Microsoft fabric community forum. Thank you lbendlin, danextian, for your inputs on this issue.
After thoroughly reviewing the details you provided, I was able to reproduce the scenario, and it worked on my end. I have used it as sample data on my end and successfully implemented it.
Date Table Dax:
CalendarTable = ADDCOLUMNS(
CALENDAR(MIN(Data[Date]), MAX(Data[Date])),
"Year", YEAR([Date]),
"Month", FORMAT([Date], "MMM")
)
Previous Year’s Cost Measure:Prev_Year_Cost = CALCULATE(SUM(Data[Cost]), SAMEPERIODLASTYEAR(CalendarTable[Date]))
Cost Increase YoY Measure:
Sales Growth from Cost Increase Measure:Cost_Change_YoY = SUM(Data[Cost]) - [Prev_Year_Cost]
Previous Year’s Quantity Measure:
Prev_Year_Qty = CALCULATE(SUM(Data[Quantity]), SAMEPERIODLASTYEAR(CalendarTable[Date]))
Sales_Growth_from_Cost = [Cost_Change_YoY] * [Prev_Year_Qty]Sales Growth from Quantity Increase Measure:
Sales_Growth_from_Qty = SUMX(Data, Data[Cost] * (Data[Quantity] - Data[Prev_Year_Qty]))
I am also including .pbix file for your better understanding, please have a look into it:
I hope this could resolve your issue, if you need any further assistance, feel free to reach out. If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.- v-kpoloju-msftCommunity Support
Hi royalty123,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
- v-kpoloju-msftCommunity Support
Hi royalty123,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.