Rolling Margin Percentage Measure

JPatty

New Member
Joined
Sep 21, 2022
Messages
14
Office Version
  1. 365
  2. 2019
  3. 2011
Platform
  1. Windows
Trying to create a rolling 10 day margin measure that will return the average margin percentage for the previous 10 days. I was using the DAX below but does not exclude accounts that did not have any activity in the last 10 days. It returns the last 'Margin %' date even if it was outside of 10 days. Sample data sheet below "Business Inc" should not return a value. I think I should not use LASTDATE but I'm not sure how to make this work with the TODAY() function.

10 Day Rolling Avg =
CALCULATE (
[Margin %],
DATESBETWEEN (
'Merge1'[Date],
DATEADD ( LASTDATE ( 'Merge1'[Date] ), -10, DAY ),
LASTDATE ( 'Merge1'[Date] )
)
)

Margin % is a measure DAX below.

Margin% =
DIVIDE(
SUM('Data'[Profit]),
SUM('Data'[Revenue])
)

AccountCostRevenueProfitDate
Business Inc
100​
150​
50​
10/1/2023​
Corporation
150​
200​
50​
10/1/2023​
The Firm
100​
150​
50​
10/1/2023​
Business Inc
200​
300​
100​
10/2/2023​
Corporation
50​
200​
150​
10/2/2023​
The Firm
50​
150​
100​
10/2/2023​
Corporation
75​
50​
-25​
10/3/2023​
The Firm
75​
75​
0​
10/3/2023​
Corporation
100​
50​
-50​
10/6/2023​
The Firm
100​
50​
-50​
10/6/2023​
Corporation
300​
150​
150​
10/12/2023​
The Firm
300​
100​
200​
10/12/2023​
Corporation
300​
150​
150​
10/13/2023​
The Firm
300​
100​
200​
10/13/2023​
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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