Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Running total with 0 values

Hi, 

 

I have this table in my model :

 

DAY_ORDER    SHIFT         WEEKDAY    QUANTITY

1NIGHT_SHIFT_WDMON70
1MORNING_SHIFT_WDMON43
1EVENING_SHIFT_WDMON75
2NIGHT_SHIFT_WDTUE34
2EVENING_SHIFT_WDTUE75
2MORNING_SHIFT_WDTUE96
3NIGHT_SHIFT_WDWED43
3EVENING_SHIFT_WDWED45
3MORNING_SHIFT_WDWED64
4NIGHT_SHIFT_WDTHU0
4EVENING_SHIFT_WDTHU0
4MORNING_SHIFT_WDTHU0
5NIGHT_SHIFT_WDFRI0
5EVENING_SHIFT_WDFRI0
5MORNING_SHIFT_WDFRI0
6NIGHT_SHIFT_WKNDSAT0
6DAY_SHIFT_WKNDSAT0
7NIGHT_SHIFT_WKNDSUN0
7DAY_SHIFT_WKNDSUN0
7NIGHT_SHIFT_WDSUN0




I'm using the following measure to calculate a running total :

QUANTITY running total in WEEKDAY =
CALCULATE(
    SUM('Table'[QUANTITY ]);
    FILTER(
        CALCULATETABLE(
            SUMMARIZE('Table'; 'Table'[DAY_ORDER ] ; 'Table'[WEEKDAY]);
            ALLSELECTED('Table')
        );
        ISONORAFTER(
            'Table'[DAY_ORDER ]; MAX('Table'[DAY_ORDER ]); DESC;
            'Table'[WEEKDAY]; MAX('Table'[WEEKDAY]); DESC
        )
    )
)

Which gives me this chart :

 
 


So far so good. Now let's say today is Wednesday, which means the the values for days between Thursday and Sunday has not been updated yet(I'm retring this data from a database). I need that chart to show "0" value on those days until of course the day in question arrives and my table is updated. 
Is there any way I can pull it off with Dax/Power Query ? 
PS: I know I could use conditional formating to make days THU - SUN "disappear but I would like to have "0" values being displaye in the chart. Think of it as a running total with dynamic reset. 


Any help is appreciated! 




  • Anonymous You can create an additional measuere as

     

    Measure = SUMX('Table','Table'[QUANTITY])
     
    and new measure
    Measure 2 = IF([Measure]=0,0,[QUANTITY running total in WEEKDAY])
     

3 Replies

  • smpa01's avatar
    smpa01
    Community Champion

    Anonymous You can create an additional measuere as

     

    Measure = SUMX('Table','Table'[QUANTITY])
     
    and new measure
    Measure 2 = IF([Measure]=0,0,[QUANTITY running total in WEEKDAY])
     
    • Anonymous's avatar
      Anonymous
      Not applicable

      smpa01 Hey! That's exactly what I was looking for! Thanks for helping!! Much appreciated! 

  • hey Anonymous ,

     

    you can use WEEKDAY(TODAY() , ...) to find out the daynumber of the weekday, incorporate into your statement and return BLANK() if DAY_ORDER is greater than WEEKDAY(TODAY() , ...).

     

    Hopefully, this provides some new ideas that will help to tackle your challenge.

     

    Regards,

    Tom