Forum Discussion

ezFlow's avatar
ezFlow
Frequent Visitor
4 years ago
Solved

Summarizing values from two tables

I have Two Tabes that I want ot summarize values from Table1: 'Outgoing Inspections' - Fields: 'Outgoing Inspections'[Plant], 'Outgoing Inspections'[No. Helmets Inspected],'Outgoing Inspections'[O...
  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    4 years ago

    Hi ezFlow 

     

    To get the value of Defect Quantity , ADDCOLUMN() function is good way to return the temp table of progress. Some thing like the following:

    Helmets QA Audit (ADDCOLUMN) = 
    VAR _TEMP =
        SUMMARIZE(
            'Outgoing Inspections',
            'Outgoing Inspections'[Plant],
            'Outgoing Inspections'[Order Type],
            'Outgoing Inspections'[Id],
            "Helmets Audit", SUM( 'Outgoing Inspections'[No. Helmets Inspected] )
        )
    RETURN 
        ADDCOLUMNS(
            _TEMP,
            "Defect Quantity",
                CALCULATE(
                    SUM( 'QA Inspection Data'[Defect Quantity] ),
                    FILTER( 'QA Inspection Data', [OIID] = EARLIER( 'Outgoing Inspections'[Id] ) )
                )
        )

    the result :

     

    But in your case , also to get the table you expect, the following expression may be the best choise. This expression use the relationship maybe faster then above.

    Helmets QA Audit (SUMMARIZE) = 
    SUMMARIZE(
        'Outgoing Inspections',
        'Outgoing Inspections'[Plant],
        'Outgoing Inspections'[Order Type],
        "Helmets Audit", SUM( 'Outgoing Inspections'[No. Helmets Inspected] ),
        "Defect Quantity",
            CALCULATE(
                SUM( 'QA Inspection Data'[Defect Quantity] ),
                USERELATIONSHIP ( 'Outgoing Inspections'[Id], 'QA Inspection Data'[OIID] )
            )
    )

    result:

     

    I put my pabix file in the attachment you can refer.

     

    Best Regards

    Community Support Team _ chenwu zhu

     

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