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 would like to obtain a measurement that returns the value of the previous month even if the date filter is unchecked.
I would like it to return the value of the month before the current month if the date filter is not selected.
In this first image the filters are selected and the returned value is correct.
However, in this second image with the filters unchecked, it returns the wrong value. I would like it to return the previous month of the current month.
Below is the DAX function I am using:
Solved! Go to Solution.
Your approach will fail because neither slicer is set to single select. You are allowing your users to select multiple months as well as multiple years, so "previous month" loses its meaning.
Hi @carlosroston ,
I create two tables as you mentioned.
Then I create two measures and here are their DAX codes.
Measure =
IF(
ISFILTERED('DateTable'[Month]),
CALCULATE(
SUM('SalesData'[SalesAmount]),
FILTER(
'DateTable',
'DateTable'[Month] = SELECTEDVALUE('DateTable'[Month])
)
),
CALCULATE(
SUM('SalesData'[SalesAmount]),
FILTER(
'DateTable',
'DateTable'[Month] = MONTH(TODAY()) - 1
)
)
)
Measure 2 = 'SalesData'[Measure] - 100
But as lbendlin said, you have to keep an option in Slicer or you won't be able to accomplish what you want to accomplish.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @carlosroston ,
I create two tables as you mentioned.
Then I create two measures and here are their DAX codes.
Measure =
IF(
ISFILTERED('DateTable'[Month]),
CALCULATE(
SUM('SalesData'[SalesAmount]),
FILTER(
'DateTable',
'DateTable'[Month] = SELECTEDVALUE('DateTable'[Month])
)
),
CALCULATE(
SUM('SalesData'[SalesAmount]),
FILTER(
'DateTable',
'DateTable'[Month] = MONTH(TODAY()) - 1
)
)
)
Measure 2 = 'SalesData'[Measure] - 100
But as lbendlin said, you have to keep an option in Slicer or you won't be able to accomplish what you want to accomplish.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Your approach will fail because neither slicer is set to single select. You are allowing your users to select multiple months as well as multiple years, so "previous month" loses its meaning.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |