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
Anonymous
Not applicable

Sum of matrix rows

I have a database where on a weekly basis productions plans and actuals are being submitted. Reporting of production adherence needs to happen every 2 weeks. The problem I have occurs when I have a SKU for both weeks in production. An example below:

 

SKUWeekPlanActualsDeviationAbs. Deviation
A110090-1010
A21001202020
B1505555
B25035-1515
Totals SKU A-2002101010
Totals SKU B-10090-1010
Totals-30030000

 

The reporting happens on a SKU level (so the combination of week 1 and 2 together). For this I have created a measure to calculate deviation and absolute deviation. The individual lines in the matrix are presented correctly. However In the totals the measure is calculated as 300 against 300 resulting in 0. I do want to have a measure which sums up all the summarized lines for each SKU. My expected result would be in this case (10+10=20) for absolute deviation. Doesn't need to be inside the matrix itself, can also be a card visual. 

 

The selection of weeks happens with a slicer. I was able to create the expected output with the SUMMARIZE function, but not able to link it to interaction of the slicer input. 

PlanTable = 
var SelectedPeriod = SELECTEDVALUE(Periods[PeriodID])

return
CALCULATETABLE( 
SUMMARIZE (
    a010_PlanFulfilment;
    a010_PlanFulfilment[ItemID];
    a010_PlanFulfilment[PlantID];
    "PlanQTY"; CALCULATE (
        SUM ( a010_PlanFulfilment[Quantity] );
        FILTER ( a010_PlanFulfilment; a010_PlanFulfilment[DataTypeID] = "PLA" )
    );
    "ActQTY"; CALCULATE (
        SUM ( a010_PlanFulfilment[Quantity] );
        FILTER ( a010_PlanFulfilment; a010_PlanFulfilment[DataTypeID] = "ACT" )
    ));
    a010_PlanFulfilment[PeriodID] = "201914" || a010_PlanFulfilment[PeriodID] = "201915")
1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi ErnstBuiteman,

If you want to interactive with slicer, you could try to follow bellow steps:

I dont know your detailed sample data, so I assume that your data might be similar to below

8.png

planfulfilment = CALCULATETABLE( 
SUMMARIZE (
    SKU2,
    SKU2[SKU],SKU2[Week],SKU2[PeriodID],
   
    "PlanQTY", CALCULATE (
        SUM ( SKU2[Quantity] ),
        FILTER (SKU2, SKU2[DataTypeID]= "PLA" )
    ),
    "ActQTY",  CALCULATE (
        SUM ( SKU2[Quantity] ),
        FILTER (SKU2, SKU2[DataTypeID]= "ACT" )
    )))

9.png

Then create below measures

sku2absdev =
SUMX (
    SUMMARIZE (
        'planfulfilment',
        planfulfilment[SKU],
        "ABSDEV", ABS ( SUM ( 'planfulfilment'[ActQTY] ) - SUM ( 'planfulfilment'[PlanQTY] ) )
    ),
    [ABSDEV]
)
SKU2DEV =
SUMX (
    SUMMARIZE (
        'planfulfilment',
        'planfulfilment'[SKU],
        planfulfilment[Week],
        "DEV", SUM ( 'planfulfilment'[ActQTY] ) - SUM ( 'planfulfilment'[PlanQTY] )
    ),
    [DEV]
)

Then use planfulfilment[periodid] in slicer

10.png

Best Regards,

Zoe Zhi

 

 

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

1 REPLY 1
dax
Community Support
Community Support

Hi ErnstBuiteman,

If you want to interactive with slicer, you could try to follow bellow steps:

I dont know your detailed sample data, so I assume that your data might be similar to below

8.png

planfulfilment = CALCULATETABLE( 
SUMMARIZE (
    SKU2,
    SKU2[SKU],SKU2[Week],SKU2[PeriodID],
   
    "PlanQTY", CALCULATE (
        SUM ( SKU2[Quantity] ),
        FILTER (SKU2, SKU2[DataTypeID]= "PLA" )
    ),
    "ActQTY",  CALCULATE (
        SUM ( SKU2[Quantity] ),
        FILTER (SKU2, SKU2[DataTypeID]= "ACT" )
    )))

9.png

Then create below measures

sku2absdev =
SUMX (
    SUMMARIZE (
        'planfulfilment',
        planfulfilment[SKU],
        "ABSDEV", ABS ( SUM ( 'planfulfilment'[ActQTY] ) - SUM ( 'planfulfilment'[PlanQTY] ) )
    ),
    [ABSDEV]
)
SKU2DEV =
SUMX (
    SUMMARIZE (
        'planfulfilment',
        'planfulfilment'[SKU],
        planfulfilment[Week],
        "DEV", SUM ( 'planfulfilment'[ActQTY] ) - SUM ( 'planfulfilment'[PlanQTY] )
    ),
    [DEV]
)

Then use planfulfilment[periodid] in slicer

10.png

Best Regards,

Zoe Zhi

 

 

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

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.