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

Become a Certified Power BI Data Analyst! Prepare for Exam PL-300 with expert-led live sessions. Get registered!

Reply
Bhimashankar_D
Frequent Visitor

Get Previous Month Amount - Written Measure is not working

Hi Community,'

 

I have written below measure to get the previous month amount, but it results blank value always.

 

 

Previous Month Amount = 
CALCULATE(
    MAX(Data[Amount]),
   PREVIOUSMONTH((Data[Promished Ship Date]))
)+0

 

Visual 

Bhimashankar_D_0-1731856610816.png

 

 

 

 

 

Thanks,

Bhimashankar

 

You can download the file from here Previous Month Power BI file 

 

 

 

 

2 ACCEPTED SOLUTIONS
Jai-Rathinavel
Super User
Super User

Hi @Bhimashankar_D , I have fixed the previous month amount calculation in this file Download PBIX

I have considered the maximum month available in the data and not today's date, In your case it is December so the the previous month sales will be of november 2023. 

Output:

JaiRathinavel_0-1731860399423.png

 

Did I answer your question ? If yes, please mark my post as a solution.

 

Thanks,

Jai




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Anonymous
Not applicable

Hi @Bhimashankar_D ,

 

You need to create a calendar table:

vcgaomsft_0-1731985204976.png

And create a relationship with the 'Data' table via [Date].

vcgaomsft_1-1731985308402.png

Use the columns in the calendar table to build the hierarchy instead of Auto date/time.

 

Now you can pick the comparison pattern that suits you.

Page1:

PM Amount = CALCULATE(SUM('Data'[Amount]), DATEADD('Date'[Date], -1 , MONTH))

vcgaomsft_3-1731985957041.png

Page2:

PM Amount2 = 
VAR __curr_period = SELECTEDVALUE('Date'[Year Month Key])
VAR __prev_month_amount = CALCULATE( SUM('Data'[Amount]), REMOVEFILTERS('Date'), 'Date'[Year Month Key] = __curr_period - 1 )
RETURN
    IF( NOT ISBLANK(__curr_period), __prev_month_amount )

vcgaomsft_4-1731986050111.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Bhimashankar_D ,

 

You need to create a calendar table:

vcgaomsft_0-1731985204976.png

And create a relationship with the 'Data' table via [Date].

vcgaomsft_1-1731985308402.png

Use the columns in the calendar table to build the hierarchy instead of Auto date/time.

 

Now you can pick the comparison pattern that suits you.

Page1:

PM Amount = CALCULATE(SUM('Data'[Amount]), DATEADD('Date'[Date], -1 , MONTH))

vcgaomsft_3-1731985957041.png

Page2:

PM Amount2 = 
VAR __curr_period = SELECTEDVALUE('Date'[Year Month Key])
VAR __prev_month_amount = CALCULATE( SUM('Data'[Amount]), REMOVEFILTERS('Date'), 'Date'[Year Month Key] = __curr_period - 1 )
RETURN
    IF( NOT ISBLANK(__curr_period), __prev_month_amount )

vcgaomsft_4-1731986050111.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thanks for solution. It helps alot!

 

Thanks,

Bhimashankar

Jai-Rathinavel
Super User
Super User

Hi @Bhimashankar_D , I have fixed the previous month amount calculation in this file Download PBIX

I have considered the maximum month available in the data and not today's date, In your case it is December so the the previous month sales will be of november 2023. 

Output:

JaiRathinavel_0-1731860399423.png

 

Did I answer your question ? If yes, please mark my post as a solution.

 

Thanks,

Jai




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks @Jai-Rathinavel for solution and sharing the file. But how did you changed the 'Promished Ship Date' to normal date thing, it was date hierarchy.

 

Also one more thing, if have to get the previous month amount how it will bheave when selected month(this will be filter) is Jan 2023 now previous month becomes Dec 2022 ?

@Bhimashankar_D , I turned off Auto Time intelligence on the file settings 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you very much!

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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