Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculating running weekly total

Hello,

 

I need your help!  I am attempting to create a Power BI run chart which will illustrate weekly accumulate unit totals.  Unfortunately, the source data only documents when the units are collected for that particular week but we need to show "0" for the week on the chart were there are no data units collected.

 

We use a sperate calendar table to list weeks & year and the source data is in another table which only notes the week when data was collected - in this case only week 3 accumlated '252' units so we would like "0" place into run chart were there are no units.

 

Thank you in advance,

Don

 

YearweekUnits
20201 
20202 
20203252
20204 
20205 
20206 

 

 

  • Hi,

     

    Please try this measure to replace the original [Units]:

    Check = IF(MAX('Table'[Units])=BLANK(),0,SUM('Table'[Units]))

    And it shows:

    Best Regards,

    Giotto Zhi

     

5 Replies

  • VasTg's avatar
    VasTg
    Memorable Member

    Anonymous 

     

    You could use a IF statement to check if the value is blank and assign 0

     

    Something like this..

    Measure = IF(ISBLANK(SUM(Table[Units])),0,SUM(Table[Units]))
    
    or
    
    Measure = 
    VAR Units_Total = SUM(Table[Units])
    RETURN IF(ISBLANK(Units_Total),0,Units_Total)

     

    If it helps, mark it as a solution

    Kudos are nice too

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much.

       

      Best regards,

      Don

  • Try link

    calculate(sum(table[unit]),filter(all(table]),Table[week]<=Max(table[Week])))

     

    Better to have date table and move this calc there

    calculate(sum(table[unit]),filter(all(Date]),Date[week]<=Max(table[Week])))

     

    Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
    In case it does not help, please provide additional information and mark me with @

    Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
    Connect on Linkedin

  • v-gizhi-msft's avatar
    v-gizhi-msft
    Community Support

    Hi,

     

    Please try this measure to replace the original [Units]:

    Check = IF(MAX('Table'[Units])=BLANK(),0,SUM('Table'[Units]))

    And it shows:

    Best Regards,

    Giotto Zhi

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much - your solution has really helped.

       

      Best regards,

      Don