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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
james_wood
Frequent Visitor

How do I exclude duplicate values when I sum the revenue within a column and apply to a Card.

I have a table with 3 columns.

 

Column A contains unique IDs to various projects. 

Column B contains the revenue for each project.

Column C contains a category that means some projects in the table appear twice because they fit multiple categories. 

 

I have inserted a Card onto the page which displays total revenue for all projects, which is summing the total of Column B. However because of column C several of these projects are listed twice and so their revenues are counted twice which is not what i want.

 

I want to calculate the sum of revenue for all unique projects. I do not want to delete rows with duplicate values as other areas of my report utilise these duplicate values so it's important they remain. I simply want to sum the revenues of Column B but leaving out values where duplicates of Column A are found. Similar to how I can use the 'Count (Disctinct)' feature for unique number, I'd like to find a similar 'Sum (Distinct)' option but as per the screenshot below this doesn't exist.

 

james_wood_0-1659371380579.png

 

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@james_wood 

We can use SUMX over a GROUPBY that includes the right columns to get to what you are looking for.

Revenue Corrected = 
SUMX ( 
    GROUPBY ( YourTable,YourTable[Project ID], YourTable[Revenue]),
    YourTable[Revenue]
)

jdbuchanan71_0-1659372819357.png

 

 

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

@james_wood 

This is not a new table and should not be added as a calculated column.  It should be added as a measure and you would put the measure in your card.  You just have to change the name of the table and the columns to match your data.

Thanks! It worked. Still not sure how the GroupBy function works exactly but it does the job. Will continue the googling to understand 😄

jdbuchanan71
Super User
Super User

@james_wood 

We can use SUMX over a GROUPBY that includes the right columns to get to what you are looking for.

Revenue Corrected = 
SUMX ( 
    GROUPBY ( YourTable,YourTable[Project ID], YourTable[Revenue]),
    YourTable[Revenue]
)

jdbuchanan71_0-1659372819357.png

 

 

Many thanks @jdbuchanan71 for the quick response. I should clarify I don't have or need a table in my report. It is just a Card.

 

I've added a new column in the imported table field and copied your code but replacing with the relevant column names for ID, revenue. I just get the same huge revenue number in every row of the column (tens of $billions). Note even when I sum all values including duplicates I get abour $1Billion. As I don't know how the GROUPBY function works (a quick google doesn't give straightforward results) any further ideas?

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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