Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I would like to modify the following formula until LAST MONTH (as restriction) instead of using a Slicer (FilterYtd) :
Solved! Go to Solution.
Hi @edhans
Finally I realized that I had to change 1 line only. Leaving the following formula:
regards
Can you post a working formula? That one doesn't work. I'm not an expert on variables, but don't think you can create variables inside of a CALCULATE() function, or any other function.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThis formula works fine, but just from Sept2018 to the filtered date I choose from Slicer. The idea is to modify this to show till Last month only :
Hi @edhans ,
This formula works fine, but just from Sept2018 to the filtered date I choose from Slicer. The idea is to modify this to show till Last month only.
Thanks.
@cristianml wrote:Hi @edhans ,
This formula works fine, but just from Sept2018 to the filtered date I choose from Slicer. The idea is to modify this to show till Last month only.
Thanks.
Now it works. Your OP was missing the final ")" so I got an error playing with it.
I'm still not sure exactly what you are asking, but the following will return the last day of the previous month, so you could use this in a variable and use it as your LastDay or wherever it needs to go in that measure.
LastDayOfPreviousMonth =
CALCULATE(
EOMONTH(
ENDOFMONTH(Dates[Date]),
-1),
FILTER(Dates, Dates[Month] = MONTH(TODAY()))
)DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHi @edhans ,
Thanks for your response. But let me explain myself better. In this case what I need is to calculate my measure "[Actual Costs]" Between Sep18 and April19 (without requiring or using Slicers)
So, for Sep18 I Should use a VAR like is in the formula : VAR FirstFiscalMonth = 9 -- Set the first month of the fiscal year
and last month with somenthing like this : Date(YEAR(EDATE(today(),-1)),MONTH(EDATE(today(),-1)),1)
is possible to calculate a measure with this 2 variables ?
Thanks !
Why not just use DATESBETWEEN() as a filter?
Range of Units =
CALCULATE(
[Total Quantity],
DATESBETWEEN(
'Date'[Date],
DATE(2018,9,1),
EOMONTH(TODAY(),-1)
)
)You don't need to use a variable here. You can, but it doesn't really provide much in the way of readabity with such a simple measure, and doesn't give any of the benefits variables can give to avoid the use of EARLIER() functions.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHi @edhans
Finally I realized that I had to change 1 line only. Leaving the following formula:
regards
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 30 | |
| 28 |
| User | Count |
|---|---|
| 128 | |
| 88 | |
| 79 | |
| 67 | |
| 62 |