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
Natty_008
New Member

Date slicer showing multiple months, update measures to only show the last months data.

Hello, wondering if someone can help me with a Date slicer / measure question. 

I have a sales table linked to DATE_DIM table.

 

The Date slicer is to select the period(multiple months) so I can get the YTD sales figures. However I would like to update some of my measures to only display the last month on the date slicer.

 

For an example is I am showing YTD sales for July - December period, how can I write the measure to calculate the sales based on the last month selected in the date range (e.g. December?)

 

I was using the measure below however this is not working as I want the user to be able to look at prior months based on the dates selected in the slicer.

 

Sales last month = Calculate(sum('sales'), FILTER(Date_DIM,month(Date_DIM[FullDate])=MONTH(today())))
 
Ive also tried the following but its not working (I have a relationship between date table and sales)
 
Lastmonth_Sales =
VAR LastMonth = max(Date_DIM[YYYY-MM])
VAR LastMonthsRESULT = CALCULATE(sum('sales'),LastMonth)
RETURN
LastMonthsRESULT
 
When I check whether the last month measure works, its selects the correct month, however the above measure is giving me an error message.

 

Any help would be greatly appreciated.

Thanks

1 ACCEPTED SOLUTION
Natty_008
New Member

Solved the query - here's my updated measure

 

NEW_Sales =
VAR LastSelectedMonth = Max(Date_DIM[YYYY-MM])
 
VAR LastMonthResult
Calculate(sum('Sales'[Sales]), 
FILTER(ALL(Date_DIM),
Date_DIM[YYYY-MM]=LastSelectedMonth
)
)

RETURN
LastMonthResult

View solution in original post

1 REPLY 1
Natty_008
New Member

Solved the query - here's my updated measure

 

NEW_Sales =
VAR LastSelectedMonth = Max(Date_DIM[YYYY-MM])
 
VAR LastMonthResult
Calculate(sum('Sales'[Sales]), 
FILTER(ALL(Date_DIM),
Date_DIM[YYYY-MM]=LastSelectedMonth
)
)

RETURN
LastMonthResult

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.