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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Create a measure to sum unique values from another column and group by ID

I am working with data from a video chat app. Some entries are duplicated because they correspond to different events within a single call. The data looks as follows:

account_idcall_ideventduration
42abcdefCallStarted22
42abcdefCallEnded22
45abcdefCallStarted21
45abcdefCallEnded21
99ghijklmCallReceived13
99ghijklmCallAnswered13
99ghijklmCallEnded13
13nopqrsCallConnected39
13tuvwxyCallAccepted15
13tuvwxyCallEnded15

I need to get the sum of `duration` for each `account_id` in the table. However, I need to account for only one row per `account_id` and `call_id` combination.

I would like to get the following result from the sample data I posted above:

account_idsum_duration
42

22

4521
9913
1344

How can I achieve this?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try this:

Measure = 
  VAR __Table = 
    GROUPBY(
      'Table',
      [account_id],
      [call_id],
      "__Sum",SUMX(CURRENTGROUP(),[duration])
    )
  VAR __Result = SUMX(__Table,[__Sum])
RETURN
  __Result


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

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try this:

Measure = 
  VAR __Table = 
    GROUPBY(
      'Table',
      [account_id],
      [call_id],
      "__Sum",SUMX(CURRENTGROUP(),[duration])
    )
  VAR __Result = SUMX(__Table,[__Sum])
RETURN
  __Result


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

In the end, I opted for importing the data using `ROW_NUMBER()` directly in the SQL query to only sum the first row per combination.
However, your solution works too, so thank you!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.