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
Crydus
Helper I
Helper I

Get sum in table visual where some values are only count once

Hey there, 

I am reaching the end of my (still very limited) Power BI knowledge. I am currently creating a quality measure report where with a table visual which shows the amount of defect pieces per delivery and the table should also show the total amount of defect pieces. 
We have a distinct number for each complaint, which can have multiple items and kinds of defects. The problem here is that there are some cases where a complaint has the same item with different kinds of defects. In this cases I want to count these values only once, but I still want to be able to show them all or to filter them by their defect category. (I hope you get my point here) 

Unfortunately I can't provide any direct data from the report as it is confidential. But I have tried to create an Excel table with shows the issue. 

 
ComplaintNoItemFailureCategoryDefect Parts
C0001I0001F0110
C0002I0001F015
C0002I0001F025
C0002I0001F035
C0002I0003F025
C0003I0004F0210
C0003I0005F0110
C0003I0005F0210
C0004I0006F015
C0005I0007F025
C0006I0008F0210
C0007I0009F015

 

Currently the visual would show a sum of 85 defect parts, although in this case only 65 should be counted. 

I have tried to create a calculated column where only the first occurence in the data table is shown and all other values where ComplaintNo and Item are the same are displayed with Zero, in this case the sum would be right if no filters are applied on the visual, but as soon as I would filter the table to see only F02 complaints the sum would be wrong again. 

I hope that you can understand what I mean and are able to help me 🙂 

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
nandukrishnavs
Super User
Super User

Hi @Crydus,

Please try below the DAX measure.

 

SumOfDefectParts =
VAR summarizedTable =
    CALCULATETABLE (
        SUMMARIZE (
            'Table',
            'Table'[ComplaintNo],
            'Table'[Item],
            "DefectPartsValue", MIN ( 'Table'[Defect Parts] )
        )
    )
VAR result =
    SUMX ( summarizedTable, [DefectPartsValue] )
RETURN
    result

 

Let me know if you are finding any issues. 

 

 

Regards,

Nandu Krishna

 


Regards,
Nandu Krishna

View solution in original post

2 REPLIES 2
nandukrishnavs
Super User
Super User

Hi @Crydus,

Please try below the DAX measure.

 

SumOfDefectParts =
VAR summarizedTable =
    CALCULATETABLE (
        SUMMARIZE (
            'Table',
            'Table'[ComplaintNo],
            'Table'[Item],
            "DefectPartsValue", MIN ( 'Table'[Defect Parts] )
        )
    )
VAR result =
    SUMX ( summarizedTable, [DefectPartsValue] )
RETURN
    result

 

Let me know if you are finding any issues. 

 

 

Regards,

Nandu Krishna

 


Regards,
Nandu Krishna

This seems to be perfect. 
Now I have to only find out, why there is a difference of 2 between this measure and my old calculations but I'm pretty sure that this is due to my calculations. 

Thank you! 

 

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.