Previous month returning value

junkforhr

Board Regular
Joined
Dec 16, 2009
Messages
115
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I have the below code and it works fine apart from the fact that the most recent month and first month in the range are not giving me the result I want.

In the example below my data does not have data for September 2022, so I am not sure why this is showing in the table.

Below is split into two tables, 1st table are what I get now and the 2nd table is my desired results.

Hoping someone can assist, as it's only my 5th day using power bi.

Current Results

YearMonthCOUNT_ACTLast Month Difference
2022September10,000
2022August10,000- 1,000
2022July11,000- 1,000
2022June12,0004,000
2022May8,0008,000

Desired Results

YearMonthCOUNT_ACTLast Month Difference
2022September
2022August10,000- 1,000
2022July11,000- 1,000
2022June12,0004,000
2022May8,000


Excel Formula:
Last Month Difference = sum( Dataset[COUNT_ACT])-CALCULATE(sum( Dataset[COUNT_ACT]),PREVIOUSMONTH( Dataset[ReportingMonth].[Date]))
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
It's giving you the result you requested: the difference of one month and the previous.
When a blank cell is found, then zero is asumed, so you're getting: 10000-blank = 10000-0=10000

You need to change your code, so that when a blank cell is found, to return blank as well.
also, you would need to adjust that the following month the calculation to be performed with the last found value.
 
Upvote 0
It's giving you the result you requested: the difference of one month and the previous.
When a blank cell is found, then zero is asumed, so you're getting: 10000-blank = 10000-0=10000

You need to change your code, so that when a blank cell is found, to return blank as well.
also, you would need to adjust that the following month the calculation to be performed with the last found value.
I guess that's what I'm asking, how do I do that :-)
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,636
Members
452,662
Latest member
Aman1997

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top