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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.