Forum Discussion

Pal03's avatar
Pal03
Frequent Visitor
8 years ago
Solved

Sum over partition by

Hello everyone , I am trying to achieve this . I have a table with Date , account , segment , revenue and sector. I am trying to get 

total revenue based on Date , Account , segment only.

 

My total revenue changes  everytime there is a new date ,account , segment combination  (ignoring the sector) Please help

 

  • Hi Pal03

     

    Here is how you can do it with a calculated column

     

    Total Revenue = 
        CALCULATE(
            SUM('Table1'[Revenue]),
            FILTER(
                'Table1',
                'Table1'[Date] = EARLIER('Table1'[Date]) &&
                'Table1'[Account] = EARLIER('Table1'[Account]) &&
                'Table1'[Segment] = EARLIER('Table1'[Segment]) 
                )   
    )

7 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Microsoft Employee

    Hi Pal03

     

    Here is how you can do it with a calculated column

     

    Total Revenue = 
        CALCULATE(
            SUM('Table1'[Revenue]),
            FILTER(
                'Table1',
                'Table1'[Date] = EARLIER('Table1'[Date]) &&
                'Table1'[Account] = EARLIER('Table1'[Account]) &&
                'Table1'[Segment] = EARLIER('Table1'[Segment]) 
                )   
    )

    • Pal03's avatar
      Pal03
      Frequent Visitor

      Thanks a ton . It works !!

      • Pal03's avatar
        Pal03
        Frequent Visitor

        Actually quite excited that it works in power BI. Once again thank you :)

    • mleepin's avatar
      mleepin
      Helper I
      Just wondering - Would it be possible to do this using power query / M?
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks a lot!!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Can we do the same in Power query?