Cumulative Measure with Dynamic Time Variable

monsoonnut

New Member
Joined
Jul 1, 2016
Messages
13
Hi

I am yet again stumped by a DAX measure.
I am trying to create a measure of forecast over leadtime i.e. The cumulative forecast over the leadtime of the Product (which varies by product).

The calculation works at the Product level but fails during aggregation.
I cannot resolve how I use SUMX on a data table over a timeframe and include a third dynamic variable (Leadtime, (LT)).
LTWks is available on both the Products and data table.



The measure I am using is

CumFcst =
CALCULATE (
SUMX (data, Data[forecast] ),
DATESINPERIOD (
DimDate[datecymd],
LASTDATE ( DimDate[datecymd] ),
- ( FIRSTNONBLANK ( Data[LTwks], Data[LTwks] ) * 7 ),
DAY
),
products
)


As you can see at SKU level the Cum forecast is calculating correctly i.e. for week 19 ProductID 80316 with LTWks = 4 The CumFcst is 1710+1696+1679+1656=6741, a correct calculation and for ProductID 283907 with LTWks of 2 the CumFcst is 1229+1144=2973, again correct. However during the aggregation it is using LtWks =2. I understand that this is due to the use of FirstNonBlank but cannot find an alternative. I started using Values in its place but that causes an error. I also tried to calculate LT as a measure but couldn't get that to work either. Any help would be appreciated.


productID80316283907Total
WeekInRangeLTFcstCumFcstLTFcstCumFcstLTLT Fcst CumFcst
149349342210210211441144
24129722312212422215092653
34137036012211423215813090
44154251432294505218363417
54167558842338632220133849
64163162182345683219763989
74165164992383728220344010
84167266292404787220764110
94165866122451855221094185
104164366242486937221294238
114163066032481967221114240
124157365042502983220754186
1341621646725641066221854260
1441652647626411205222934478
1541644649028091450224534746
1641656657328901699225464999
17416796631210081898226875233
18416966675211442152228405527
19417106741212292373229395779
20422
21422
22422
23422
24422
25422

<tbody>
</tbody>
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

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