1

i have spent alot time on this with this, but not sure why this aint working.i have the dataset like:

part    loc    wk       demand  cumulative
123-1   1000   20_wk01   10      10
123-1   1000   20_wk02   15      25
123-1   1000   20_wk03   12      27
123-2   1020   20_wk01   13      13
123-2   1020   20_wk02   14      27
123-2   1020   20_wk03   15      42

all the columns are "text" and i have a part filter. "Demand" is a measure. Hence my code tried is:

RunningTotal = CALCULATE(demand, FILTER( ALLSELECTED( 'table'[part]),
 'table'[part]<=MAX('table'[part]) ) ,
FILTER(ALLSELECTED('table'[loc]),'table'[loc]<=MAX('table'[loc])
),FILTER(ALLSELECTED('table'[wk]),'table'[wk]<=MAX('table'[wk])))

please assist. I am struggling with part which is not working as desired.

1 Answers1

0

You can do the same with a Measure as below-

cumulative = 

var cur_row_wk = min(table[wk])

return
CALCULATE(
    'table'[demand],
    FILTER(
        ALLEXCEPT('table',table[part], table[loc]),
        'table'[wk] <= cur_row_wk
    )
)

Output-

enter image description here

mkRabbani
  • 16,295
  • 2
  • 15
  • 24
  • thanks mkRabbani. What about the location field (loc) ? should i define the variable? – ramesh reddy Feb 14 '22 at 18:06
  • 1
    great. Mind blowing. Really great piece of code and i learned it. Thanks again.I have marked it as an answer and currently stackoverflow not allowing me for upvote. – ramesh reddy Feb 15 '22 at 07:59