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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DRossi
Helper III
Helper III

Find Distinct values in one column and return sum of values of another column

Hello,

 

I have a dataset that has columns Table1[FA_ID] and Table1[Job Duration].

 

I need to create a measure that goes like:

 

Find Distinct values in FA_ID and then through the corresponding FA_IDs, return the sum of Job Durations.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Not Tested but try

Measure =
Sumx(summarize(Table1,Table1[FA_ID], "_dur",max(Table1[Job Duration])),_dur)

OR

Measure = 
VAR __id = MAX ( 'Table1'[FA_ID] )
VAR __dur = CALCULATE ( MAX( 'Table'[Job Duration] ), ALLSELECTED ( 'Table1' ),  'Table1'[FA_ID] = __id ) 
RETURN CALCULATE ( sum ( __dur ), VALUES ( 'Table1'[id] ), 'Table1'[id] = __id )

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

Not Tested but try

Measure =
Sumx(summarize(Table1,Table1[FA_ID], "_dur",max(Table1[Job Duration])),_dur)

OR

Measure = 
VAR __id = MAX ( 'Table1'[FA_ID] )
VAR __dur = CALCULATE ( MAX( 'Table'[Job Duration] ), ALLSELECTED ( 'Table1' ),  'Table1'[FA_ID] = __id ) 
RETURN CALCULATE ( sum ( __dur ), VALUES ( 'Table1'[id] ), 'Table1'[id] = __id )

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

First measure and you nailed it.

 

I just added the square brackets around the last dur

 

Thanks very much.


amitchandak
Super User
Super User

When you put that in matrix and sum job Duration, You should get the same output? Or any other visual

Thanks for your reply @amitchandak 

Yes this is true, however, becuase there are duplicates of FA ID, this means there are duplicates of job duration.

 

If I add them in to a matrix or chart, I can see that the count of FA IDs is the same as the count of job durations, if I change to distinct count of FA IDs then FA IDs reduce, great, but the job duration count is still the same as the count of FA IDs. Hence this would then skew the sum of job durations.

 

I can't change to distinct of job durations as there will be many the same. 

 

I need something that finds the DISTINCT FA ID and the corresponding job duration.

Hence why I would require a formula for the above.

Let me know what you think.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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