cancel
Showing results for 
Search instead for 
Did you mean: 
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.

View solution in original post

amitchandak
Super User IV
Super User IV

@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)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

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 III
Super User III

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

 






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
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors