The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have a calculatetion which looks at every expense and income before a given date.
This is fairly simple since I just put the date from my kalender table in a filter and selected the before option.
This works as intended, but I also want to see what this number was lastmonth so I can see the development.
I have tried with the previous month function. Calculate([measure],previousmonth(calender[date])).
But it doesn't work. I think my problem is that instead of calender[date] I need to make it clear that it should be the max of the selected date.
In short I want to use the same measure and filter to figure out what my measure was one month prior.
Solved! Go to Solution.
Hi @ThomasWeppler ,
According to your description, here's my solution.
Create a measure.
Pre Measure =
VAR _C =
MAXX ( ALLSELECTED ( 'Date' ), 'Date'[Date] )
VAR _Pre =
DATE ( YEAR ( _C ), MONTH ( _C ) - 1, DAY ( _C ) )
RETURN
CALCULATE ( [measure], FILTER ( ALL ( 'Date' ), 'Date'[Date] = _Pre ) )
In my sample, the measure is MAX([Income])+MAX([Expense]), it get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ThomasWeppler ,
According to your description, here's my solution.
Create a measure.
Pre Measure =
VAR _C =
MAXX ( ALLSELECTED ( 'Date' ), 'Date'[Date] )
VAR _Pre =
DATE ( YEAR ( _C ), MONTH ( _C ) - 1, DAY ( _C ) )
RETURN
CALCULATE ( [measure], FILTER ( ALL ( 'Date' ), 'Date'[Date] = _Pre ) )
In my sample, the measure is MAX([Income])+MAX([Expense]), it get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@ThomasWeppler TRy this:
LAst MOnth = CALCULATE(Measure, DATEADD(Calendar[Date],-1,MONTH))
OR try this:
LAst MOnth = CALCULATE(Measure, DATEADD(SelectedValue(Calendar[Date]),-1,MONTH))
@ThomasWeppler , previousmonth takes min date, not the max , Try datesmtd with dateadd
Calculate([measure],datesmtd(dateadd(calender[date],-1,month)))
Why previousmonth does not give result when datesmtd is giving it: https://youtu.be/1KkoJehRVeg