Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Kopec
Helper I
Helper I

Sum the Unique values to appropriate value

Can anybody help me with this:
Sum the unique values ​​in column "B" to the appropriate value in column "A".

 Kopec_1-1738313390235.png

Thank you,

Jan

 

 

2 ACCEPTED SOLUTIONS

@Kopec - You can use the below to get your desired answer (just change the column names):

 

VAR _table = SUMMARIZE( 'Table', 'Table'[Column1],  'Table'[Column2] )

RETURN
SUMX( _table, 'Table'[Column2])

 

mark_endicott_0-1738328031657.png

 

mark_endicott_1-1738328051613.png

 

If this works for you please accept as the solution to help others with the same challenge. 

View solution in original post

Hi @Kopec 

The formula i offered can work in power pivot.

vxinruzhumsft_0-1738660167715.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
Kopec
Helper I
Helper I

Hi Mark,
ist look great, but I need to get value for every row in the table. According to the picture (column "RESULT"): 

Kopec_0-1738328863526.png

 

Hi,

Thanks for the solution mark_endicott  and DataNinja777  offered, and i want to offer some more information for user to refer to.

hello @Kopec , mark_endicott 's solution is right, you can use it as a calculated column .

Column =
VAR a =
    SUMMARIZE ( 'Table', [Column1], [Column2] )
RETURN
    SUMX ( FILTER ( a, [Column1] = EARLIER ( 'Table'[Column1] ) ), [Column2] )

Output

vxinruzhumsft_0-1738561436533.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Hi, 

for Power BI it works great.

Can anybody help me how to make it work in Power Pivot?
And can anybody know, why the below formula doesnt work?

=CALCULATE (SUMX(TABLE; Column B);VALUES(Column B); ALLEXCEPT(TABLE; Column A)

)

Hi @Kopec 

The formula i offered can work in power pivot.

vxinruzhumsft_0-1738660167715.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-xinruzhu-msft - Thank you, I always forget about calculated columns! Can I request we mark my solution please as this one is solved!

@Kopec - As far as I'm aware this will be nearly impossible in a measure due to the way Power BI groups identical rows in it's visualisations. Even if you add an index column to undo the grouping, there will still be an issue with the way we have to use SUMMARIZE to remove the row duplication to get the result you want.

There may be a solution out there for you but I've tried a few, including adding a duplicate of the table, and none seem to work.

 

I suggest you think about why it is necessary to present your data in this way, and if the solution I have provided works, or use Excel. 

DataNinja777
Super User
Super User

Hi @Kopec ,

 

You can achieve this in Power BI using DAX with a measure that sums the unique values of Column B for each corresponding value in Column A. The following DAX measure accomplishes this:

Result =
SUMX (
    VALUES ( 'Table'[Column B] ),
    'Table'[Column B]
)

This measure works by extracting the unique values in Column B for each group in Column A using VALUES('Table'[Column B]), then iterating over these unique values and summing them with SUMX(...). If you prefer to do this transformation in Power Query, you would first remove duplicates from Column B while keeping only unique values for each group in Column A. Then, you would group by Column A and sum the unique values in Column B. Finally, merge this result back to the original table to display the calculated sum in a new column.

 

Best regards,

 

 

 

It's almost done, but I need: 

SUMX (
    VALUES ( 'Table'[Column B] ),
    'Table'[Column A]
)

In Column "A" is string.... I have got a mistake. I suppose because of that STRING values in Column A.
Can you help me?

@Kopec - You can use the below to get your desired answer (just change the column names):

 

VAR _table = SUMMARIZE( 'Table', 'Table'[Column1],  'Table'[Column2] )

RETURN
SUMX( _table, 'Table'[Column2])

 

mark_endicott_0-1738328031657.png

 

mark_endicott_1-1738328051613.png

 

If this works for you please accept as the solution to help others with the same challenge. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.