Forum Discussion
Sum the Unique values to appropriate value
- 1 year ago
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])If this works for you please accept as the solution to help others with the same challenge.
- Anonymous1 year ago
Hi Kopec
The formula i offered can work in power pivot.
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 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?
- mark_endicott1 year ago
Super User
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])If this works for you please accept as the solution to help others with the same challenge.