Forum Discussion

kolturra's avatar
kolturra
Helper IV
7 years ago
Solved

Cummulative SUM DAX ERROR

Hi,

 

I have issue DAX fomula with running total. I have done running total calculation in column F, what i have identify that my DAX formula is not populating same like manual calculation. Difference of running total i kept in column G.

help me understand where is the problem in my DAX.

 

I have updated excel file in below link

https://onedrive.live.com/embed?cid=B6A84FD93EE33256&resid=B6A84FD93EE33256%2120824&authkey=AEbwMccjxLUw60U&em=2%22

 

Below is the formula, i am using to get running total.

RunningTotal = CALCULATE(SUM(a[Energy]),FILTER(a,a[NewDay]<=EARLIER(a[NewDay])&&a[TimeFactor]<=EARLIER(a[TimeFactor])))
 
Thanks,
K Raghavender Rao
  • Anonymous's avatar
    Anonymous
    7 years ago

    Sorry about that.  Try this one:

    Column = 
    var __CurrentCreatedTime = Table2[CreatedTime]
    RETURN
    
    CALCULATE(
        SUM( Table2[Energy] ),
        FILTER( 
            ALL( Table2 ),
            __CurrentCreatedTime >= Table2[CreatedTime]
        )
    )

    Did a check, and looks like the new column is what you would want:

    Also, be sure to set your data types in Power Query. 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    try this code for a calculated column:

    Column = 
    var __CurrentDay = Table2[NewDay]
    var __CurrentTime= Table2[TimeFactor]
    
    RETURN
    
    CALCULATE(
        SUM( Table2[Energy] ),
        FILTER( 
            ALL( Table2 ),
            __CurrentDay >= Table2[NewDay]
            && __CurrentTime >= Table2[TimeFactor]
        )
    )
    • kolturra's avatar
      kolturra
      Helper IV

      Hi Anonymous ,

       

      Thanks for your reply.

       

      Whatever DAX which you have shared and i have created are showing same results but both the DAX fomulas shows same errors at one place. Below screenshot for your reference. Can you plesae help me on this.

       

       

       

       

       

       

       

       

       

      Thanks,

      K Raghavender Rao

      • Anonymous's avatar
        Anonymous
        Not applicable

        Sorry about that.  Try this one:

        Column = 
        var __CurrentCreatedTime = Table2[CreatedTime]
        RETURN
        
        CALCULATE(
            SUM( Table2[Energy] ),
            FILTER( 
                ALL( Table2 ),
                __CurrentCreatedTime >= Table2[CreatedTime]
            )
        )

        Did a check, and looks like the new column is what you would want:

        Also, be sure to set your data types in Power Query.