Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

running sum based on dates

 

Hi Expert,

I wanted to add running column based on running sum as third column in power BI based on date

 
Date         SalesCount
20220223               2499
20220303               1
  • Hi Anonymous 

     

    You need to create a relationship between Date table and Sales table on date column (one-to-many, single direction). Then create the following measure

    Cumulative Total =
    CALCULATE (
        SUM ( 'Sales'[SalesCount] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
        )
    )
    

     

    Here are some blogs for your reference:

    Power BI: Calculating Cumulative Totals for Time Periods

    Computing running totals in DAX - SQLBI

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.

4 Replies

  • Anonymous , a new column

    sumx(filter(Table, [Date] < earlier([Date]) ), [sales Count])

     

    a new measure =

    sumx(filter(allselected(Table), Table[Date] < max(Table[Date]) ), Table[sales Count])

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Expert,

      but the saledate is coming from Datetable and  salecount from sales table how we can differentiate in calculation

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Expert,

    but the saledate is coming from Datetable and  salecount from sales table how we can differentiate in calculation

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi Anonymous 

     

    You need to create a relationship between Date table and Sales table on date column (one-to-many, single direction). Then create the following measure

    Cumulative Total =
    CALCULATE (
        SUM ( 'Sales'[SalesCount] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
        )
    )
    

     

    Here are some blogs for your reference:

    Power BI: Calculating Cumulative Totals for Time Periods

    Computing running totals in DAX - SQLBI

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.