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
Anonymous
Not applicable

previous month without filter

Hi all,

 

I would like to have always the current last month displayed in this table like in the picture below. However, I don't want to select the current date every time, I want the measure to pull the previous month automatically.

This is currently my formula. But here I still need the date filter. I only ever need the previous month, all other months do not interest me in this matter.

 

prevMonth = CALCULATE(sum('sales'[delivery quantity]), PREVIOUSMONTH(Kalender[Datum]))
 

How is this possible?

 

JustDub_0-1651051623023.png

 

Thanks!

 

1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

[prevMonth] = 
    var today_ = today()
    // get the first day of the previous month
    var dayStart = EOMONTH(today_, -2) + 1
    // get the last day of the previous month
    var dayEnd = EOMONTH(today_, -1)
    var result =
        CALCULATE(
            sum( 'sales'[delivery quantity] ),
            all( Kalender[Datum] ),
            Kalender[Datum] >= dayStart,
            Kalender[Datum] <= dayEnd
        )
    return
        result

View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

[prevMonth] = 
    var today_ = today()
    // get the first day of the previous month
    var dayStart = EOMONTH(today_, -2) + 1
    // get the last day of the previous month
    var dayEnd = EOMONTH(today_, -1)
    var result =
        CALCULATE(
            sum( 'sales'[delivery quantity] ),
            all( Kalender[Datum] ),
            Kalender[Datum] >= dayStart,
            Kalender[Datum] <= dayEnd
        )
    return
        result
amitchandak
Super User
Super User

@Anonymous , Try like this. It will work for both selected and not selected

 

Switch Period =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _max = eomonth(_max,-1)
var _min = eomonth(_max,-2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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