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
Archie123
New Member

Calculate a sum for a family related to an item

I have a table of dimensional measurements, each entry representing an evaluation of a particular dimension on a particular part:

 

Measurement Table

Measurment NumberPart NumberDim_idOut of Spec Flag

1

001001_dim_01

1

2001001_dim_020
3001001_dim_031
4001001_dim_040
5002002_dim_010
6002002_dim_020
7001001_dim_01

1

8001001_dim_021

 

I'd like to know how each dimension contributes to the overal "out of spec" count for a given part, but I'm struggling to have a measure that calculates for the Dim_id, the total number of times a the related part number is out of spec.

 

As an example of what I'd like:

If Part Number [001] was out of spec 4 times

and Dim_id [001_dim_01] was out of spec 2 times,

then [001_dim_01] contributes to 50% of the out of spec measurements for Part Number [001]

 

Resulting Table:

Dim_idOut of Spec FlagDIM OOSPart Number OOS% OOS Contribution
001_dim_01

1

2

4

50%

001_dim_0201425%
001_dim_0311425%
001_dim_040040%
002_dim_010000%
002_dim_020000%

 

For some reason when I use the function:

CALCULATE(

   SUM('Measurement Table'[Out of Spec Flag]),

   ALLEXCEPT('Measurement Table', 'Measurement Table'[Part Number])
)

 

I still get the total sum of Out of Spec Flag in the table (the same for each dim)

 

Resulting Table:

Dim_idOut of Spec FlagDIM OOSPart Number OOS
001_dim_01

1

2

4

001_dim_02014
001_dim_03114
001_dim_04004
002_dim_01004
002_dim_02004

 

I also have a table of distinct Part Numbers with a relationship to the Measurement table, but when I use the function:

CALCULATE(

   SUM('Measurement Table'[Out of Spec Flag]),

   ALLEXCEPT('Part Numbers', 'Part Numbers'[Part Number])
)

 

The result is the total Out of Spec sum for the specific dim, not the sum for the related part number.

 

Resulting Table:

Dim_idOut of Spec FlagDIM OOSPart Number OOS
001_dim_01

1

2

2

001_dim_02011
001_dim_03111
001_dim_04000
002_dim_01000
002_dim_02000

 

Does anyone have insight into what could help?

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

These measures work

DIM OOS = SUM(Data[Out of Spec Flag])
Part number OOS = CALCULATE([DIM OOS],ALL(Data[Dim_id]))
% OOS contribution = if([Part number OOS]=0,0,[DIM OOS]/[Part number OOS])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

These measures work

DIM OOS = SUM(Data[Out of Spec Flag])
Part number OOS = CALCULATE([DIM OOS],ALL(Data[Dim_id]))
% OOS contribution = if([Part number OOS]=0,0,[DIM OOS]/[Part number OOS])

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

Thank you for you response, but I think the measures as you have them written only work because the original table I provided did not have any OOS for Part Number 2.  I've provided a more detailed table of example data below.

 

In this case, your measures would calculate a Part Number OOS of 7 for all parts rather than the correct number of 5 for Part 1 and 2 for Part 2. I apologize I didn't provide a better example table in the first post.

 

Capture.JPG

 

Updated Measurement Table

Measurement Number

Part Numberdim_idPN_dim_idOOS Flag

1

1dim_01001_dim_011
21dim_02001_dim_020
31dim_03001_dim_031
41dim_04001_dim_040
52dim_01002_dim_010
62dim_02002_dim_020
72dim_03002_dim_030
82dim_04002_dim_041
91dim_01001_dim_011
101dim_02001_dim_021
111dim_03001_dim_031
121dim_04001_dim_040
132dim_01002_dim_011
142dim_02002_dim_020
152dim_03002_dim_030
162dim_04002_dim_040

Hi,

My suggested measures work perfectly well if you drag Part Number to the visual.  See the screenshot.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you, that's what I'll do.

 

Can you help me understand: If there's a relationship between the Dim_id and the Part Number, why isn't it possible to get the desired result without the Part Number field?

Hi,

It is only because of the Part Number field that you are being able to see duplicate Dim ID.  If you remove that field, each Dim ID will appear only once.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.