Forum Discussion

imran_uridetech's avatar
imran_uridetech
Frequent Visitor
5 years ago
Solved

Summarize

I am trying to Summarize a Table and calculate running total in a new Table
As you can see in the attached pictures, the TempTable (1st Picture) with its DAX codes
and when I try to SUMX the Column "Summary" from TempTabel to my result table its not workig at row level, I want to add up only if the values in [Order] is less than or equal to the row value in my result table [PnL_Order], somthing similar to a running total.

Any help is appreciated.

 

  • mahoneypat's avatar
    mahoneypat
    5 years ago

    Please try it with this change

     

    VAR Result1=SUMMARIZE(PnL,[PnL_Order],"Amount1",
    VAR _curOrder=MAX(PnL[PnL_Order])
    Return SUMX(FILTER(TempTable, [Order] <=_curOrder), [Summary])
     
    Pat

4 Replies

  • az38's avatar
    az38
    Community Champion

    hi imran_uridetech 

    not the best but maybe quickest solution

    var result =
    summarize(pnl, [Pnl_Order], "Amount1", 
    var _curOrder = MAX ([Pnl_Order]) 
    RETURN
    CALCULATE(SUMX(temptable, [Summary]), temptable[Order] <= _curOrder )
    • imran_uridetech's avatar
      imran_uridetech
      Frequent Visitor

      I cannot use "temptable[Order]" its coming from VAR above, so instead I tried to use it inside a FILTER and the result is same:


      VAR Result1=SUMMARIZE(PnL,[PnL_Order],"Amount1",
      VAR _curOrder=MAX(PnL[PnL_Order])
      Return CALCULATE(SUMX(TempTable,[Summary]),FILTER(TempTable,[Order]<=_curOrder)))
      • mahoneypat's avatar
        mahoneypat
        Microsoft Employee

        Please try it with this change

         

        VAR Result1=SUMMARIZE(PnL,[PnL_Order],"Amount1",
        VAR _curOrder=MAX(PnL[PnL_Order])
        Return SUMX(FILTER(TempTable, [Order] <=_curOrder), [Summary])
         
        Pat