Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello everyone!
I have a yearly execution view where I would like to switch between the YTD and MTD.
I have the following to measures:
Orders MTD
=
CALCULATE (
[Orders],
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Fiscal Year]
= MAX ( 'Calendar'[Year] )
&& 'Calendar'[Date]
<= MAX ( 'Calendar'[Date] )
&& 'Calendar'[Fiscal Month Number]
= MAX ( 'Calendar'[Fiscal Month Number] )
)
)
Orders YTD =
CALCULATE (
[Orders],
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Fiscal Year]
= MAX ( 'Calendar'[Year] )
&& 'Calendar'[Date]
<= MAX ( 'Calendar'[Date] )
)
)
How can I create a Slicer for switching between MTD and YTD?
Solved! Go to Solution.
Create a new table using enter data option and then list the measures names. Then create a slicer out of the column and use this DAX.
SelectedMeasure =
VAR MeasureName =
VALUES ( Joshua[Measure Name] )
VAR Result =
IF (
HASONEVALUE ( Joshua[Measure Name] ),
SWITCH ( TRUE (), MeasureName = "Total Sales", [Total Sales], [Total Cost] )
)
RETURN
Result
Hi @joshua1990 ,
Sorry for that in Power BI, we cannot create a slicer using Measure.
If you want to control measure through slicer, you need to create a new table that contains the Measure’s name like @AntrikshSharma said.
Maybe you can refer this solved post.
If you have any question, please kindly ask here and we will try to resolve it.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Create a new table using enter data option and then list the measures names. Then create a slicer out of the column and use this DAX.
SelectedMeasure =
VAR MeasureName =
VALUES ( Joshua[Measure Name] )
VAR Result =
IF (
HASONEVALUE ( Joshua[Measure Name] ),
SWITCH ( TRUE (), MeasureName = "Total Sales", [Total Sales], [Total Cost] )
)
RETURN
Result
Thanks for your reply!
Is there maybe another way?
With your approach, I have to edit several measures.
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
136 | |
117 | |
101 | |
71 | |
61 |