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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Kurt4597
Helper I
Helper I

Filtering Measure By Date

Hello All,

 

I have been stuck on this issue for a few hours and really can't seem to fix it. Any help would be greatly appreciated. 

DateDim Table

Kurt4597_4-1662053968964.png

 

 

Deals Table

Kurt4597_5-1662053988156.png

 

 

I have a measure called "Average Cost" which is the Total Cost / Total number of deals. This measure works as expected and can be filtered by whichever month has been selected. My issue is when I try to create a measure for Average cost Last month.  To do this I have created a measure called PreviousDate

Kurt4597_2-1662053183450.png

PreviousDate measure - This value is generated depending on whatever is selected in the filter. For example I have currently selected May 2022, so the measure shows 2022-04 

 

I am then trying to filter the Deals table, where the YearMonth Column = Previous Month measure. See below 

Kurt4597_3-1662053433138.png

 

What I have tried 

Average Cost Last Month =
CALCULATE([Average Cost],
all('DateDim'[YearMonth]), filter(DateDim, DateDim[YearMonth] = [PreviousDate])
)
 
I have tried using this formula but it just gives me a blank value.  I have played around with it and tried a few different versions of this formula but I still can not get the Average Cost measure for the previous month to the selected month from date filter. Any help would be massively appreciated!
 
-

 




 

 

5 REPLIES 5
rsbin
Community Champion
Community Champion

@Kurt4597 ,

Looks to me like you are comparing a MonthYear column to a YearMonth value (2022-04).

Try changing your [MonthYear] in your Measure to [YearMonth].

Regards,

Apologies, that was just a mistake I made when pasting over from the sample file. The issue is still present

rsbin
Community Champion
Community Champion

@Kurt4597 ,

Can you please post the Measure you have for "Previous Date"?

Unfortunately, my network here won't allow me to access your link above.

PreviousDate = date(if( Values(DateDim[Month]) = 1, Values(DateDim[Year]) -1, Values(DateDim[Year])), if(Values(DateDim[Month]) = 1,12, (Values(DateDim[Month])-1)), "01")

rsbin
Community Champion
Community Champion

@Kurt4597 ,

I was able to download your file.  Took a quick look but am sorry that I haven't been able to decipher the issue.  I would like to suggest you re-post your question in a new thread.  This will give someone else an opportunity to try to resolve your issue.  Also fix the typo/error in your Average Cost formula. 

 

I will give your file another look later today if I get the chance.

Regards,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.