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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
KW123
Helper V
Helper V

Previous Month

Hi, 

I need to get the MAX (or last value) of a previous month for a measure [WhatdoesYTDtotalneedtobe]

I have tried using this DAX as both a measure and a column, but it only returns blanks. 

 
CALCULATE([What does YTD total need to be],
PREVIOUSMONTH('Dates'[Date]))

I have also tried

var current_month= MONTH(TODAY()) return  CALCULATE(SUM('2022 GOals'[WhatdoesYTDtotalneedtobe]),FILTER('Dates',MONTH('Dates'[Month])=current_month -1))

Any ideas? 

Thanks!

4 REPLIES 4
KW123
Helper V
Helper V

If I use this DAX: 

Prevmonth =
CALCULATE(
SUMX(
'2022 Goals',
'2022 Goals'[What does YTD total need to be]
),
FILTER(
ALL(Dates),
Dates[Year] = MAXX (Dates, Dates[Year]) &&
Dates[Month] = MAXX(Dates,Dates[Month]) -1
))

I still get a blank result.  However if I add
 
&&
Dates[Date] = MAXX(Dates,Dates[Date]) -1

then it gives me the max of the current month but blanks for the first and last day of that month.  So I am assuming it's -1 of the day rather than the month.  

The Date table shares a relationship by month name to the goals table.  I have tried using [Month name] instead but no result. 
KW123
Helper V
Helper V

I created a column which shows me the last day of the previous month: 


Last day of previous month =
PREVIOUSMONTH('Dates'[Last day of month])

However when I try to use it in a calculate measure this is the error: 

A Function 'PLACEHOLDER' has been used in a True/False expression that is used as a table filter expression.  This is not allowed.' 

The DAX I am using: 
Lastdayprevmonthvalue =
CALCULATE([What does YTD total need to be],'2022 Goals'[Last day of previous month])



Greg_Deckler
Super User
Super User

@KW123 Hard to say without actual example data. You can get last month by using EOMONTH([Date], -1) that will get you the last day of the month, is that what you want? Or do you want to get MAXX of some value that exists in the last month?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks for the reply! 

I have a separate column already with the previous days.  I'm looking for a measure which will return the last day (is the same as the max) $ value from the previous month. 

My DAX measure for the column I need is 

What does YTD total need to be =
VAR A = [Accounting goal calc-c]
VAR B = [Daily Goal]
VAR CurrentIndex =
SELECTEDVALUE ( Dates[FD2] )
VAR MaxIndex =
CALCULATE ( MIN ( Dates[FD2] ), ALLEXCEPT ( Dates, Dates[Date] ) )
RETURN
IF (
DAY ( SELECTEDVALUE ( Dates[Date] ) ) = 1
&& MONTH ( SELECTEDVALUE ( Dates[Date] ) ) = 1,
0,

IF ( CurrentIndex <> BLANK (), A + ( MaxIndex - CurrentIndex ) * B )
)
Basically a running total based on the day of the week.  I need the MAX value to be able to use it in another measure to calculate something for a separate column.  I hope that helps a bit more. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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