Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ThomasWeppler
Impactful Individual
Impactful Individual

How to calculate everything before a given date one month prior

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.

before date.png

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.

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

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.

vkalyjmsft_0-1650528649598.png

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.

View solution in original post

3 REPLIES 3
v-yanjiang-msft
Community Support
Community Support

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.

vkalyjmsft_0-1650528649598.png

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.

Tahreem24
Super User
Super User

@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))

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
amitchandak
Super User
Super User

@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

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors