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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Srikantht
Helper II
Helper II

Previous Month Calculation getting Wrong

Hi All,

 

I am trying to get previous month values by using the below dax but getting wrong values. Can any one help in this to get the expected output. Thanks in Advance. 

 

Srikantht_0-1697523631270.png

Dax : 

Previous Month = CALCULATE(SUM(value),
ALL(Table),
PREVIOUSMONTH(Table[Date]))

 

 

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @Srikantht ,

Please try create a measure with below dax formula, but you need adjust it according to your actua calculate context:

Previous month =
VAR cur_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _result =
    CALCULATE (
        MAX ( [Current Month] ),
        FILTER ( ALL ( 'Table' ), DATEDIFF ( cur_date, [Date], MONTH ) = -1 )
    )
RETURN
    _result

vbinbinyumsft_0-1697695777669.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-binbinyu-msft
Community Support
Community Support

Hi @Srikantht ,

Please try create a measure with below dax formula, but you need adjust it according to your actua calculate context:

Previous month =
VAR cur_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _result =
    CALCULATE (
        MAX ( [Current Month] ),
        FILTER ( ALL ( 'Table' ), DATEDIFF ( cur_date, [Date], MONTH ) = -1 )
    )
RETURN
    _result

vbinbinyumsft_0-1697695777669.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Uzi2019
Super User
Super User

Hi @Srikantht 
Try below dax:
Prev Month= calculate( sum(value), dateadd(Date,-1,Month))

If  my post helps you. please give kudos and accept it as a solution!

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Sorry, it's not working.

Hi @Srikantht 
what answer you are getting??
I am getting the correct result through Dateadd function

Uzi2019_0-1697526536060.png


If my post helps give kudos and accept it as solution!

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

I am getting same as current month output. 

Srikantht_0-1697532946764.png

 

My dax : Previous Month = CALCULATE(SUM(Table[Value]),DATEADD('CALENDAR'[Date],-1,MONTH))

 

hi  @Srikantht 
Try his measure

Uzi2019_0-1697537247986.png


If my posy helps please give kudos and accept it  as a solution!
Thanks.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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