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
JBF1978
Regular Visitor

Data Duplication

I have a spreadsheet listing parts needed to build tools. One part can be used in multiple tools (Tool Type), and the quantity needed depends on the tool's configuration and tool type. There isn't a one-to-one relationship, as different tools and configurations require different amounts of the same part. When I try to forecast based on orders in our system, the quantities sometimes double or triple incorrectly. Example table attached, I have this for multiple parts, but this is a good example overall. 
Having trouble getting this to sum up correctly, any help would be appreciated. 
 
Part #Part NameToolTool ConfigurationQty Needed
100010Plug24DM12930622
100010Plug24DML11366024
100010Plug24DMLS11365144
100010Plug24DMLSX11148144
100010Plug24DMLX11047044
100010Plug24DMS11365144
100010Plug24DMSX11148144
100010Plug24DMX12930722
100010Plug24DUL13019322
100010Plug24DULS13019122
100010Plug24DULSX13019022
100010Plug24DULX13019222
100010Plug26DM12930824
100010Plug26DML12270348
100010Plug26DML12271348
100010Plug26DMLS12270148
100010Plug26DMLS12271148
100010Plug26DMLSX12270048
100010Plug26DMLSX12271048
100010Plug26DMLX12270248
100010Plug26DMLX12271248
100010Plug26DMX12930924
100010Plug30DM11560356
100010Plug30DM12931028
100010Plug30DML11560356
100010Plug30DMLS11560556
100010Plug30DMLSX11560656
100010Plug30DMLX11560456
100010Plug30DMX12931128
100010Plug30DUL13019928
100010Plug30DULS13019728
100010Plug30DULSX13019628
 
2 ACCEPTED SOLUTIONS
rajendraongole1
Super User
Super User

Hi @JBF1978  - Try using SUMX to ensure proper summation based on distinct Tool Configuration

Total Qty Needed =
SUMX(
VALUES(YourTable[Tool Configuration]),
MAX(YourTable[Qty Needed])
)

 

also in your power query editor, please do group by :

Go to Power Query (Transform Data) and:

Group By Part #, Tool, Tool Configuration, and sum Qty Needed.
Remove duplicate entries before loading into Power BI.

 

I hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Anonymous
Not applicable

Hi,rajendraongole1 ,thanks for your concern about this issue.

Your answer is excellent!
And I would like to share some additional solutions below.

Hi,@JBF1978 .I am glad to help you.
Like this?
Instead of 22, 44, the data is aggregated to 44, 88, etc.

vjtianmsft_0-1738132541523.png

If you can't find a suitable visual to display the data, I hope my suggestions below will be helpful to you.
Since you can only add one field as a grouping condition in a line chart, you mentioned that “the number of fields required depends on the configuration of the tool and the type of tool”.
So you could try to place one field on the X axis and one field on the Legend field, to avoid data aggregation (double or triple the data as you mentioned).

vjtianmsft_1-1738132590117.png

 

Perhaps you might consider adding a slicer

vjtianmsft_2-1738132633205.png

If you want to consider other options, grouping the Qty calculation based on the two categorization fields is a good way to go:

What this metric does is calculate the sum of the Qty Needed for all rows that have the same Part #, Part Name, Tool Configuration, and Tool as the current row (i.e., grouping based on these four fields, I'm assuming you have multiple lesser types of [Part Name],[Part#])

 

M_groupNeed = 
VAR _part =
    MAX ( 'TestTable'[Part #] )
VAR _partName =
    MAX ( 'TestTable'[Part Name] )
VAR _toolConfig =
    MAX ( 'TestTable'[Tool Configuration] )
VAR _tool =
    MAX ( 'TestTable'[Tool] )
// _part: get the Part # value of the current row.
// _partName: get the Part Name value of the current row.
// _toolConfig: get the Tool Configuration value of the current row.
// _tool: get the Tool value for the current row.
VAR _groupNeed =
    CALCULATE (
        SUM ( 'TestTable'[Qty Needed] ),
        FILTER (
            ALL ( TestTable ),
            'TestTable'[Part #] = _part
                && 'TestTable'[Part Name] = _partName
                && 'TestTable'[Tool Configuration] = _toolConfig
                && 'TestTable'[Tool] = _tool
        )
    )
RETURN
    _groupNeed

 

You can also use the ALLEXCEPT function, he can be prior to the same effect, according to the specified field to group the data, and then perform each group within the aggregation operations

 

M_ExceptGroupNeed = 
CALCULATE (
    SUM ( 'TestTable'[Qty Needed] ),
    ALLEXCEPT (
        TestTable,
        'TestTable'[Part #],
        'TestTable'[Part Name],
        'TestTable'[Tool Configuration],
        'TestTable'[Tool]
    )
)

 


I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
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

2 REPLIES 2
Anonymous
Not applicable

Hi,rajendraongole1 ,thanks for your concern about this issue.

Your answer is excellent!
And I would like to share some additional solutions below.

Hi,@JBF1978 .I am glad to help you.
Like this?
Instead of 22, 44, the data is aggregated to 44, 88, etc.

vjtianmsft_0-1738132541523.png

If you can't find a suitable visual to display the data, I hope my suggestions below will be helpful to you.
Since you can only add one field as a grouping condition in a line chart, you mentioned that “the number of fields required depends on the configuration of the tool and the type of tool”.
So you could try to place one field on the X axis and one field on the Legend field, to avoid data aggregation (double or triple the data as you mentioned).

vjtianmsft_1-1738132590117.png

 

Perhaps you might consider adding a slicer

vjtianmsft_2-1738132633205.png

If you want to consider other options, grouping the Qty calculation based on the two categorization fields is a good way to go:

What this metric does is calculate the sum of the Qty Needed for all rows that have the same Part #, Part Name, Tool Configuration, and Tool as the current row (i.e., grouping based on these four fields, I'm assuming you have multiple lesser types of [Part Name],[Part#])

 

M_groupNeed = 
VAR _part =
    MAX ( 'TestTable'[Part #] )
VAR _partName =
    MAX ( 'TestTable'[Part Name] )
VAR _toolConfig =
    MAX ( 'TestTable'[Tool Configuration] )
VAR _tool =
    MAX ( 'TestTable'[Tool] )
// _part: get the Part # value of the current row.
// _partName: get the Part Name value of the current row.
// _toolConfig: get the Tool Configuration value of the current row.
// _tool: get the Tool value for the current row.
VAR _groupNeed =
    CALCULATE (
        SUM ( 'TestTable'[Qty Needed] ),
        FILTER (
            ALL ( TestTable ),
            'TestTable'[Part #] = _part
                && 'TestTable'[Part Name] = _partName
                && 'TestTable'[Tool Configuration] = _toolConfig
                && 'TestTable'[Tool] = _tool
        )
    )
RETURN
    _groupNeed

 

You can also use the ALLEXCEPT function, he can be prior to the same effect, according to the specified field to group the data, and then perform each group within the aggregation operations

 

M_ExceptGroupNeed = 
CALCULATE (
    SUM ( 'TestTable'[Qty Needed] ),
    ALLEXCEPT (
        TestTable,
        'TestTable'[Part #],
        'TestTable'[Part Name],
        'TestTable'[Tool Configuration],
        'TestTable'[Tool]
    )
)

 


I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


rajendraongole1
Super User
Super User

Hi @JBF1978  - Try using SUMX to ensure proper summation based on distinct Tool Configuration

Total Qty Needed =
SUMX(
VALUES(YourTable[Tool Configuration]),
MAX(YourTable[Qty Needed])
)

 

also in your power query editor, please do group by :

Go to Power Query (Transform Data) and:

Group By Part #, Tool, Tool Configuration, and sum Qty Needed.
Remove duplicate entries before loading into Power BI.

 

I hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.