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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors