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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
shanipowerbi
Helper III
Helper III

Calculate Last month Amount

Hi

Hope you all are fine and healthy

 

I need very little help from you guys

 

I have two Columns

Date                    Amount         Last Month

01 Jan 2020         $ 5000

02 Feb 2020        $ 6000              $ 5000

03  March 2020   $ 7000             $ 6000

04 April 2020       $ 8000             $ 7000

 05 May 2020                              $ 8000

 

Here you can see when I use previous month dax it will give me April 2020 amount in May 2020 in Last Month Column, I want to stop that calculation till last month means future month not required.

 

Please help me to resolve this

 

Regards

 

Zeeshan

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @shanipowerbi ,

 

Your method is right. You just need to add filter conditions to your formula.

last_month = IF(MAX('table'[date].[Date]<TODAY(),CALCULATE(SUM('table'[amount]),DATEADD('table'[date].[Date],-1,MONTH)))

test_last_month.PNG

 

Best Regards,
Liang
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

5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hi @shanipowerbi ,

 

Your method is right. You just need to add filter conditions to your formula.

last_month = IF(MAX('table'[date].[Date]<TODAY(),CALCULATE(SUM('table'[amount]),DATEADD('table'[date].[Date],-1,MONTH)))

test_last_month.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@shanipowerbi , You can try like

LMTD QTY forced=
var _max = date(year(today()),month(today())-1,day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)

Not Worked,

 

Let me Re-collaborate

I am trying to get the previous month's Amount in Current month and I am successful to get this. But the problem I am facing that I am unable to stop this calculation further for future months.

For Example 

I have two columns 

 

Date            Amount

Jan              1000

Feb              2000

Mar             3000

April            500 (Which is not yet end)

 

For the previous amount, I can use the formula 

CALCULATE(SUM('Invoice Data'[Amount),DATEADD('Invoice Data'[InvoiceDate].[Date],-1,MONTH))
by Applying this formula I am getting this Answer
 

Date            Amount                Previous Amount       

Jan              1000

Feb              2000                   1000

Mar             3000                    2000

April            500                     3000

May                                        500

 

In the above result, I want data still March because its complete, but don't want April (Current Month) or any future month

 

parry2k
Super User
Super User

@shanipowerbi change last month measure as below

 

Last Month = 
<your existing measure>
* DIVIDE ( SUM ( Table[Amount] ), SUM ( Table[Amount] ) )

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Not Worked,

Let me Re-collaborate I am trying to get the previous month's Amount in Current month and I am successful to get this. But the problem I am facing that I am unable to stop this calculation further for future months.

 

For Example I have two columns

Date              Amount

Jan                1000

Feb               2000

Mar               3000 

April              500 (Which is not yet end)

 

For the previous amount, I can use the formula CALCULATE(SUM('Invoice Data'[Amount),DATEADD('Invoice Data'[InvoiceDate].[Date],-1,MONTH))

by Applying this formula I am getting this Answer

 

Date             Amount               Previous Amount

Jan               1000

Feb               2000                     1000

Mar              3000                      2000

April             500                        3000

May                                            500

 

In the above result, I want data still March because its complete, but don't want April (Current Month) or any future month

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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