Forum Discussion

nok's avatar
nok
Icon for Advocate II rankAdvocate II
1 year ago
Solved

Create column that sums all values ​​with the same ID

Hello!

I have a table that follows this structure:

IDValue
A3
A5
B2
C7
D9
D2
D11
E5


I want to create a new column that will sum the value of the "Value" column for all the same IDs.

The expected result would be something like this:

ID     Value   SUM_ValueById
A38
A58
B22
C77
D922
D222
D1122
E55


How can I do this?

  • Hi nok  ,

    You can achieve this by creating a calculated column in Power BI using DAX.

    DAX Formula:

    SUM_ValueById = CALCULATE( SUM('Table'[Value]), FILTER('Table', 'Table'[ID] = EARLIER('Table'[ID])) )


    Please mark this as solution if it helps you. Appreciate Kudos.

2 Replies

  • rsbin's avatar
    rsbin
    Icon for Community Champion rankCommunity Champion

    nok ,

    Your Calculated Column is:

    SumID = CALCULATE( SUM([Value]),
               ALLEXCEPT( 'Table', 'Table'[ID] ))
     
    Regards,
  • Hi nok  ,

    You can achieve this by creating a calculated column in Power BI using DAX.

    DAX Formula:

    SUM_ValueById = CALCULATE( SUM('Table'[Value]), FILTER('Table', 'Table'[ID] = EARLIER('Table'[ID])) )


    Please mark this as solution if it helps you. Appreciate Kudos.