Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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!!
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
109 | |
94 | |
84 | |
32 | |
27 |