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

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
707
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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
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,215,096
Messages
6,123,074
Members
449,094
Latest member
mystic19

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