cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
murali5431
Helper III
Helper III

Reprt builder expression for calculation based on distinct values in a column

Hi,

 

I have a power BI report builder which has duplicated rows (column A) as below. I need to calculate sum of column B based on unique values in column A. Please let me know the report builder expression.

 

Column AColumn B
PartA150
PartB100
PartA150
PartB100
PartC200
PartC200

 

I need the expression which would calculate sum of PartA + PartB + PartC = 150+100+200 = 450

 

Thanks to assist.

 

Regards,

Muralidhar

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@murali5431 
A simple measure should do:

Measure = SUMX(SUMMARIZE('Table',[Column A],'Table'[Column B]),[Column B])
 
And if there are always 2 repeated values, you can also use:
Measure = SUMX(DISTINCT('Table'[Column B]),[Column B])
V-pazhen-msft_0-1620973825658.png

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
V-pazhen-msft
Community Support
Community Support

@murali5431 
A simple measure should do:

Measure = SUMX(SUMMARIZE('Table',[Column A],'Table'[Column B]),[Column B])
 
And if there are always 2 repeated values, you can also use:
Measure = SUMX(DISTINCT('Table'[Column B]),[Column B])
V-pazhen-msft_0-1620973825658.png

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

@V-pazhen-msft It did work when I tried it in the power BI desktop where I have built the dataset. But, when I import this measure to the report builder report to which dataset is connected, it just gives me the first row value. Can you let me know what needs to be tweaked?

HashamNiaz
Solution Sage
Solution Sage

Hi !

Does the values in ColumnB will always be exactly same for repeted ColumnA members. How you want the calculation to work if you have have PartA with 2 distinct values in ColumnB, 150 & 120. What you want to do in this scenrio.

 

Regards,

@HashamNiaz 

Values in ColumnB will always be exactly same for repeted ColumnA members, so we can ignore the scenario of columnB having different values for a value in column A. 

Thanks for checking!

 

Regards,

Muralidhar

Hi !

I would solve this like below;

 

1) Create a new table using DAX;

Go to Modelling Tab -> New Table, provide following DAX

NewTable = SUMMARIZE(Table, Table[ColumnA], Table[ColumnB])


Table is the name of your table, you can replace it with your table name in the formula.

 

Now create a measure to sum column B, use following DAX

NewSum = SUM(NewTable[ColumnB])

 

Hope this will solve your requirement.

 

Regards,

Hasham

Helpful resources

Announcements
collabdays lisbon

CollabDays Lisbon - 26 November 2022

Sessions include practical, hands-on experience that will help you take the next step in your career and know-how.

Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.