March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I have a sales table that has 4 fields Region, Prod category, Calendar Month and Net Sales.
I would like to see one matrix table in Power BI in such a way that I compare two months of data based on two date slicers namely date slicer 1 and date slicer 2. Also I want to calculate the deviation between the months.
If in Date slicer 1 Jan and in Date slicer 2 Feb is selected then the output should be like below
If in Date slicer 1 Jan and in Date slicer 2 Mar is selected then the output should be like below
How is this possible in Power BI.?
Solved! Go to Solution.
Hi, @SDK0415
Thanks for @Uzi2019 and @Kishore_KVN reply. The current version of the matrix does not support the use of Measure as a column, you can try the following method to create multiple Measure to be placed in the Card.
Measure:
Diviation Electronics =
VAR _maxCalendarMonth =
CALCULATE ( MAX ( 'Table'[Month Number] ) )
VAR _minCalendarMonth =
CALCULATE ( MIN ( 'Table'[Month Number] ) )
VAR _maxMonthElectronicsNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _maxCalendarMonth
&& 'Table'[Prod Category] = "Electronics"
)
VAR _minMonthElectronicsNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _minCalendarMonth
&& 'Table'[Prod Category] = "Electronics"
)
RETURN
_maxMonthElectronicsNetSales - _minMonthElectronicsNetSales
Diviation Furniture =
VAR _maxCalendarMonth =
CALCULATE ( MAX ( 'Table'[Month Number] ) )
VAR _minCalendarMonth =
CALCULATE ( MIN ( 'Table'[Month Number] ) )
VAR _maxMonthFurnitureNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _maxCalendarMonth
&& 'Table'[Prod Category] = "Furniture"
)
VAR _minMonthFurnitureNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _minCalendarMonth
&& 'Table'[Prod Category] = "Furniture"
)
RETURN
_maxMonthFurnitureNetSales - _minMonthFurnitureNetSales
Diviation% Electronics =
VAR _maxCalendarMonth =
CALCULATE ( MAX ( 'Table'[Month Number] ) )
VAR _minCalendarMonth =
CALCULATE ( MIN ( 'Table'[Month Number] ) )
VAR _maxMonthElectronicsNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _maxCalendarMonth
&& 'Table'[Prod Category] = "Electronics"
)
VAR _minMonthElectronicsNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _minCalendarMonth
&& 'Table'[Prod Category] = "Electronics"
)
RETURN
DIVIDE (
_maxMonthElectronicsNetSales - _minMonthElectronicsNetSales,
_minMonthElectronicsNetSales
)
Diviation% Furniture =
VAR _maxCalendarMonth =
CALCULATE ( MAX ( 'Table'[Month Number] ) )
VAR _minCalendarMonth =
CALCULATE ( MIN ( 'Table'[Month Number] ) )
VAR _maxMonthFurnitureNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _maxCalendarMonth
&& 'Table'[Prod Category] = "Furniture"
)
VAR _minMonthFurnitureNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _minCalendarMonth
&& 'Table'[Prod Category] = "Furniture"
)
RETURN
DIVIDE (
_maxMonthFurnitureNetSales - _minMonthFurnitureNetSales,
_minMonthFurnitureNetSales
)
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi, @SDK0415
Thanks for @Uzi2019 and @Kishore_KVN reply. The current version of the matrix does not support the use of Measure as a column, you can try the following method to create multiple Measure to be placed in the Card.
Measure:
Diviation Electronics =
VAR _maxCalendarMonth =
CALCULATE ( MAX ( 'Table'[Month Number] ) )
VAR _minCalendarMonth =
CALCULATE ( MIN ( 'Table'[Month Number] ) )
VAR _maxMonthElectronicsNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _maxCalendarMonth
&& 'Table'[Prod Category] = "Electronics"
)
VAR _minMonthElectronicsNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _minCalendarMonth
&& 'Table'[Prod Category] = "Electronics"
)
RETURN
_maxMonthElectronicsNetSales - _minMonthElectronicsNetSales
Diviation Furniture =
VAR _maxCalendarMonth =
CALCULATE ( MAX ( 'Table'[Month Number] ) )
VAR _minCalendarMonth =
CALCULATE ( MIN ( 'Table'[Month Number] ) )
VAR _maxMonthFurnitureNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _maxCalendarMonth
&& 'Table'[Prod Category] = "Furniture"
)
VAR _minMonthFurnitureNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _minCalendarMonth
&& 'Table'[Prod Category] = "Furniture"
)
RETURN
_maxMonthFurnitureNetSales - _minMonthFurnitureNetSales
Diviation% Electronics =
VAR _maxCalendarMonth =
CALCULATE ( MAX ( 'Table'[Month Number] ) )
VAR _minCalendarMonth =
CALCULATE ( MIN ( 'Table'[Month Number] ) )
VAR _maxMonthElectronicsNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _maxCalendarMonth
&& 'Table'[Prod Category] = "Electronics"
)
VAR _minMonthElectronicsNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _minCalendarMonth
&& 'Table'[Prod Category] = "Electronics"
)
RETURN
DIVIDE (
_maxMonthElectronicsNetSales - _minMonthElectronicsNetSales,
_minMonthElectronicsNetSales
)
Diviation% Furniture =
VAR _maxCalendarMonth =
CALCULATE ( MAX ( 'Table'[Month Number] ) )
VAR _minCalendarMonth =
CALCULATE ( MIN ( 'Table'[Month Number] ) )
VAR _maxMonthFurnitureNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _maxCalendarMonth
&& 'Table'[Prod Category] = "Furniture"
)
VAR _minMonthFurnitureNetSales =
CALCULATE (
SUM ( 'Table'[Net Sales] ),
'Table'[Month Number] = _minCalendarMonth
&& 'Table'[Prod Category] = "Furniture"
)
RETURN
DIVIDE (
_maxMonthFurnitureNetSales - _minMonthFurnitureNetSales,
_minMonthFurnitureNetSales
)
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi @SDK0415
Try below video these videos will help you.
https://www.youtube.com/watch?v=_QmF0q2JfvQ
https://www.youtube.com/watch?v=vzI9T3Wdpak
https://www.youtube.com/watch?v=knXFVf2ipro&t=914s
https://www.youtube.com/watch?v=TF0lPIYjJfs&t=1s
https://www.youtube.com/watch?v=DGRCLcfUHM4&t=608s
https://www.youtube.com/watch?v=O0VsTLDTjss&t=332s
I hope I answered your question!
Combination of all above video would give you desired result.
Hello @SDK0415 ,
You have to use SELECTEDVALUE DAX function to select the period and implement it in the Deviation calculation.
For example:
Deviation =
VAR A = SELECTEDVALUE(DATESLICER1)
VAR B = SELECTEDVALUE(DATESLICER2)
RETURN
B-A
This is just example. Depends on your data change accordingly.
If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |