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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Thumper369
Frequent Visitor

Power BI Measure - Summarize distinct values

I am trying to find the sum for defective effort but I need it to only sum distinct WorkItemId where Links.TargetWorkItem.WorkItemId is not blank


Measures I currently have:


Defective Effort =
CALCULATE(SUM('Work items with direct links'[Effort]),NOT(ISBLANK('Work items with direct links'[Links.TargetWorkItem.WorkItemId])))

 

For the Sum in the table below (and in the chart) I am wanting the total to be 31 not 35, The Effort for ID 10829 is Getting counted twice

Thumper369_1-1648591344671.png

 

Thumper369_2-1648591531978.png

Thanks for the help.  I have searched for a few hours and can not find one that is workign for me.  



1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Thumper369 ,

 

Here's the solution.

1.The dummy data I created.

vstephenmsft_0-1648783853641.png

 

2.Create a measure to calculate the Defective Effort.

Defective Effort =
CALCULATE (
    SUM ( 'Work items with direct links'[Effort] ),
    FILTER (
        ALLSELECTED ( 'Work items with direct links' ),
        [ID] = MAX ( 'Work items with direct links'[ID] )
            && [Links.TargetWorkItem.WorkItemId] <> BLANK ()
    )
)

 

3.You can see that the total in the table is incorrect, so we just need to create a new measure to add them correctly.

vstephenmsft_1-1648784324813.png

 

4.The new measure.

Total = 
VAR _table =
    ADDCOLUMNS (
        VALUES ( 'Work items with direct links'[ID] ),
        "DE", [Defective Effort]
    )
RETURN
    SUMX ( _table, [DE] )

vstephenmsft_2-1648784523885.png

 

 

If you're still confused, please provide some dummy data and expected results.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Thumper369
Frequent Visitor

The problem I was having turned out to be the relationship betwen two tables.  Created a table with only one entry for each sprint # then tied all the tables back to that table with a 1:many instead of many:many.  This resolved the problem.  

Thanks everyoe for your help. 

v-stephen-msft
Community Support
Community Support

Hi @Thumper369 ,

 

Here's the solution.

1.The dummy data I created.

vstephenmsft_0-1648783853641.png

 

2.Create a measure to calculate the Defective Effort.

Defective Effort =
CALCULATE (
    SUM ( 'Work items with direct links'[Effort] ),
    FILTER (
        ALLSELECTED ( 'Work items with direct links' ),
        [ID] = MAX ( 'Work items with direct links'[ID] )
            && [Links.TargetWorkItem.WorkItemId] <> BLANK ()
    )
)

 

3.You can see that the total in the table is incorrect, so we just need to create a new measure to add them correctly.

vstephenmsft_1-1648784324813.png

 

4.The new measure.

Total = 
VAR _table =
    ADDCOLUMNS (
        VALUES ( 'Work items with direct links'[ID] ),
        "DE", [Defective Effort]
    )
RETURN
    SUMX ( _table, [DE] )

vstephenmsft_2-1648784523885.png

 

 

If you're still confused, please provide some dummy data and expected results.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Thumper369 , Try a measure like

 


sumx(summarize('Work items with direct links','Work items with direct links'[Links.TargetWorkItem.WorkItemId],'Work items with direct links'[Effort]), [Effort])

 

or

 


sumx(summarize('Work items with direct links','Work items with direct links'[Links.TargetWorkItem.WorkItemId],"_1", max( 'Work items with direct links'[Effort])), [_1])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Sorry, neither of those work.  I tried them on their own, but they did not constarin it to only rows that had  targetworkItem.WorkItemId.   
I tried them in my measurement but they still do not exclude the duplicate of 108829

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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