Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
michaelmack
New Member

Count Qty of Parts in an assembly

Hello.

I have an invoiced quantity measure which counts sales of a part number.

eg.

A2412, A 2413, A2144.

I have also Kits that have different part numbers but are made up of the original part numbers.

eg.

K1 = 1x A2412, 4x A2413.

K2 = 2x A2412, 3x A2414.

Both kits and Single parts can be purchased.

 

When looking at total invoiced quantity the kits only show up as 1 part when it should actually show total qty of all parts used to make the kit.

I think I can attack this in several ways.

I could create a new table which includes the kit numbers and how many value it would represent or I could create a dax which explicitly states how many to substitute.

The list of kits is quite large though ~120 different kits, so maintinaing another table would be the preferred option i'm guessing.

Kit's can include up to around 30 parts.

Total Part numbers are in the thousands.

Wondering what your thoughts are on the best way to accurately count the total parts. What's the best approach?

Any example DAX to support pulling data from another table to manipulate only those part numbers that appear in the table otherwise default to the reported qty in the invoice quantity measure.

Do I need to put a 1 next to each part then tally the qty for the kits and reference that table somehow?

 

Thanks in advance for suggestions.

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I would create a Kits table which has 3 columns: Kit Part No, which is the part number for the kit as it appears in the invoice; Actual Part No, which is the base part number; Quantity. This table doesn't need to have a relationship to the invoice table.

You could then create a measure like

Invoiced quantity =
SUMX (
    Invoice,
    VAR CurrentPartNo = Invoice[Part no]
    VAR KitParts =
        CALCULATE (
            SUM ( Kits[Quantity] ),
            TREATAS ( { CurrentPartNo }, Kits[Kit Part no] )
        )
    RETURN
        COALESCE ( Invoice[Quantity] * KitParts, Invoice[Quantity] )
)

If the part number is a base part, rather than a kit, then the KitParts variable will return blank and so the COALESCE will return the invoice quantity.

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

I would create a Kits table which has 3 columns: Kit Part No, which is the part number for the kit as it appears in the invoice; Actual Part No, which is the base part number; Quantity. This table doesn't need to have a relationship to the invoice table.

You could then create a measure like

Invoiced quantity =
SUMX (
    Invoice,
    VAR CurrentPartNo = Invoice[Part no]
    VAR KitParts =
        CALCULATE (
            SUM ( Kits[Quantity] ),
            TREATAS ( { CurrentPartNo }, Kits[Kit Part no] )
        )
    RETURN
        COALESCE ( Invoice[Quantity] * KitParts, Invoice[Quantity] )
)

If the part number is a base part, rather than a kit, then the KitParts variable will return blank and so the COALESCE will return the invoice quantity.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.