Power Pivot ....MEasure to take Month over Month Difference

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
755
Office Version
  1. 365
  2. 2010
so my source data has two dates in column A....this month and previous month

there's another column "expenses"

im trying to make a measure/dax formula that takes the the difference between this months expenses vs last month for each row of data in the data set and obviously put that in the pivot
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
You can create a DAX measure to calculate the difference between this month's expenses and last month's expenses for each row of data in your dataset and then use that measure in your PivotTable. You can use the DAX `EARLIER` function to reference the current row's values and calculate the difference.

Here's a sample DAX measure for this purpose:

```DAX
MonthlyExpenseDifference =
SUMX(
FILTER(
'YourTableName', -- Replace with the name of your table
'YourTableName'[Date] = MAX('YourTableName'[Date]) -- Filter the current month's data
),
'YourTableName'[Expenses]
)
-
SUMX(
FILTER(
'YourTableName', -- Replace with the name of your table
'YourTableName'[Date] = MAX('YourTableName'[Date]) - 1 -- Filter the previous month's data
),
'YourTableName'[Expenses]
)
```

Here's how this DAX measure works:

1. `SUMX` is used to iterate through the table.
2. The `FILTER` function is used to filter the table to include only the rows for the current month and the previous month.
3. The first `SUMX` calculates the sum of expenses for the current month.
4. The second `SUMX` calculates the sum of expenses for the previous month.
5. The difference between the two sums gives you the monthly expense difference for each row.

Make sure to replace `'YourTableName'` with the actual name of your table and `'YourTableName'[Date]` and `'YourTableName'[Expenses]` with the actual column names for dates and expenses in your table.

After you create this DAX measure, you can add it to your PivotTable as a value to see the monthly expense differences for each row of data.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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