cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.

Dax :

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

1 ACCEPTED SOLUTION
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
``````

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.

6 REPLIES 6
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
``````

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.

Super User

Hi @Srikantht
Try below dax:

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!!!
Helper II

Sorry, it's not working.

Super User

Hi @Srikantht
I am getting the correct result through Dateadd function

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!!!
Helper II

I am getting same as current month output.

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

Super User

hi  @Srikantht
Try his measure

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

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors