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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Datafruit
Helper I
Helper I

Measure to sum unique values in column with duplicate values based on a another column

Hi guys

 

Pretty new to PBI and have a problem with creating a measure, that does what I need it to do. Basically I have a table where I have a bunch of data and I need to sum "Transaction fee" column, but since there are multiple entries for one customer in one country, the transaction fee is also "duplicated". And if I sum it up like this, then for the highlighted instance, the amount would be 4x bigger, which is a BIG NO NO 😄

Datafruit_0-1628859285458.png


Anyway, I hope you can help, since I've spent like a good 2,5h on this and searched and tried different options that people have posted, but without luck. 
So it would need to be a measure, other columns used in slicer should be able to affect the result. And here is a sample data set if some of you might be interested.
Sample data 

Thanks a lot

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Datafruit Perhaps:

Measure =
  VAR __Table = 
    DISTINCT(
      SELECTCOLUMNS('Table',"fee",[transaction_fee],"nr",[customer_nr],"country",[country])
    )
RETURN
  SUMX(__Table,[fee])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Datafruit Perhaps:

Measure =
  VAR __Table = 
    DISTINCT(
      SELECTCOLUMNS('Table',"fee",[transaction_fee],"nr",[customer_nr],"country",[country])
    )
RETURN
  SUMX(__Table,[fee])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

This solution looks like it will fit for my data issues as well, however I cannot get correct syntax to work for the Measure.  Can you help with the VAR command and when we say "Table" are we referring to the table with my data or some temporary table?

@Greg_Deckler Works, thank you! 🙂

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.