Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello!
I have sales by product and a slicer by date "BEFORE".
The result I want to get in one measure is:
- if no date is selected in the slicer, then sales for the month (MTD)
- if a date is selected in the slicer, then sales for that date.
Is this possible and how?
Solved! Go to Solution.
Thanks solution from @vicky_ , your solution is great!
Hi, @pani_victoria
Based on your description, I have created the following sample data:
I have the following two measures:
I created a date table using the following DAX expression:
Table 2 = CALENDAR(MIN('Table'[Date]),TODAY())
I'm using columns from the entire date table in the slicer:
I use the following DAX expression to create a measure that switches the MTD to the current day's breakdown:
sales =
VAR _seleteddate =
SELECTEDVALUE ( 'Table 2'[Date] )
RETURN
IF (
ISBLANK ( _seleteddate ),
[Sales MTD],
CALCULATE ( [Sales amount], 'Table'[Date] = _seleteddate )
)
Here are the results:
When the date slicer is not checked, the MTD is displayed:
If the date is selected, the details of the current day are displayed:
I've provided the PBIX file used this time below.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks solution from @vicky_ , your solution is great!
Hi, @pani_victoria
Based on your description, I have created the following sample data:
I have the following two measures:
I created a date table using the following DAX expression:
Table 2 = CALENDAR(MIN('Table'[Date]),TODAY())
I'm using columns from the entire date table in the slicer:
I use the following DAX expression to create a measure that switches the MTD to the current day's breakdown:
sales =
VAR _seleteddate =
SELECTEDVALUE ( 'Table 2'[Date] )
RETURN
IF (
ISBLANK ( _seleteddate ),
[Sales MTD],
CALCULATE ( [Sales amount], 'Table'[Date] = _seleteddate )
)
Here are the results:
When the date slicer is not checked, the MTD is displayed:
If the date is selected, the details of the current day are displayed:
I've provided the PBIX file used this time below.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
From the wording, I assume that you have a single-date slicer.
If so, then you can try wrap your calculations in an if statement. Something like:
Your Measure = IF(HASONEVALUE('Slicer Table'[Date]),
// ... your calculations for sales
, // your calculations for MTD
)
User | Count |
---|---|
84 | |
73 | |
67 | |
42 | |
35 |
User | Count |
---|---|
109 | |
56 | |
52 | |
45 | |
43 |