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
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
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.