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

Reporting on bundled product orders

Good morning community,

 

I have an existing report that shows quantity of product sold from an invoice table. We have started selling bundles of products eg 1 x ProductX, 2 x ProductY etc under a different SKU. I need the report to show quantites of the component SKUs and ignore the bundle SKU. Fortunately, for each invoiceID, our invoice table contains seperate records for the bundle sku AND the components BUT it shows 0 quantity for the components. I have created a lookup table listing the Bundle SKU, the component SKU and quantity. 

I can easily create a column to check if the SKU on this record is listed as the SKU of a bundle. Where i am struggling, is figuring out how to identify if the SKU on the invoice record is part of a bundle.

An example of invoice data:

InvoiceIDSKUQuantity
12345BundleQA2
12345ProductA0
12345ProductB0

An example of the lookup table

Bundle SKUComponentSKUQuantity
BundleQAProductA3
BundleQAProductB2

So what i am aiming to get, is a column - lets call it ReportQty - that will show 0 on the invoice record for BundleQA, 3 for ProductA and 2 for ProductB.

I am thinking i need something like matching SKUs in Invoice that ARE a bundle with a subset filtered table on invoice_sku = bundlelookup_componentSKU

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Nathaniel_C 

 Looking at the construct of your formulae and thinking about how to return the bundleSKU value, led me to the following.

 

I have a calculated column (BundledSKU) that evaluates TRUE/FALSE if the invoice record SKU is a SKU in [Bundled SKU Matrix]. Then I can use that as a criteria in a Calculate(Firstnonblank()) to identify the relevant bundle sku name.

 

Can this be streamlined or is there a better way?

 

BundledQty = (LOOKUPVALUE('Bundled SKU Matrix'[Qty],'Bundled SKU Matrix'[SKU],CALCULATE(FIRSTNONBLANK(invoicedetails[SKU],TRUE()),filter(invoicedetails,invoicedetails[BundleSKU]=TRUE() && invoicedetails[_invoiceid_value] = EARLIER(invoicedetails[_invoiceid_value]))),'Bundled SKU Matrix'[BundleSKU],invoicedetails[SKU])+0) * CALCULATE(FIRSTNONBLANK(invoicedetails[Quantity],TRUE()),filter(invoicedetails,invoicedetails[BundleSKU]=TRUE() && invoicedetails[_invoiceid_value] = EARLIER(invoicedetails[_invoiceid_value])))+0

 

 

View solution in original post

5 REPLIES 5
Nathaniel_C
Super User
Super User

Hi @Anonymous ,
Not sure if I understand your question but try this:

Report Quantity =
LOOKUPVALUE ( Lookup[Quantity], Lookup[ComponentSKU], MAX ( InvoiceData[SKU] ) )

sku.PNG

 

 
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





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

Proud to be a Super User!




Hi @Anonymous ,
Or with a zero:

Report Quantity =
IF (
    LOOKUPVALUE ( Lookup[Quantity], Lookup[ComponentSKU], MAX ( InvoiceData[SKU] ) )
        = BLANK (),
    0,
    LOOKUPVALUE ( Lookup[Quantity], Lookup[ComponentSKU], MAX ( InvoiceData[SKU] ) )
)


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel 





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

Proud to be a Super User!




Hi @Anonymous ,
I was thinking that for each invoice, you may want to know the total of each of the components. So a measure to multiply the number of bundles by each of the components that make up that bundle.

Report Qty =
VAR _curInID =
    MAX ( InvoiceData[InvoiceID] )
VAR _maxQtyBundle =
    CALCULATE (
        MAX ( InvoiceData[Quantity] ),
        ALLEXCEPT ( InvoiceData, InvoiceData[InvoiceID] ),
        InvoiceData[Quantity] <> 0
    )
VAR _total =
    _maxQtyBundle
        * (
            IF (
                LOOKUPVALUE ( Lookup[Quantity], Lookup[ComponentSKU], MAX ( InvoiceData[SKU] ) )
                    = BLANK (),
                0,
                LOOKUPVALUE ( Lookup[Quantity], Lookup[ComponentSKU], MAX ( InvoiceData[SKU] ) )
            )
        )
RETURN
    _total



sku2.PNG

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
 





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

Proud to be a Super User!




Anonymous
Not applicable

@Nathaniel_C  thanks for the suggestions. I had (sorta) gotten this far also. Unfortunatley that will not always work. ProductA could be a component of more than 1 bundle sku and each bundle SKU could have a different quantity of ProductA. 

The below shows a snippet of the Bundle SKU table and the 2nd image a count of how many bundles each SKU is a component of.

 PBI 2 BUNDLE.PNG

PBI BUNDLE.PNG

So it needs a second criteria identifying which SKU in the BundleSKU table to return the quantity of ComponentSku. For that criteria it needs to know which SKU, so needs a method to compare the SKUs in the invoice table for that invoice ID for a matching Sku in the BundleSKU table. 

Something like - lookupvalue(BundleSKUTable[Quantity],BundleSKUTable[SKU],Matches(A SKU in InvoiceID),BundleSKUTable[BundleSKU],InvoiceData[SKU])

Can we perform a loop (for/next) within a VAR DAX equation?

 

 

Anonymous
Not applicable

@Nathaniel_C 

 Looking at the construct of your formulae and thinking about how to return the bundleSKU value, led me to the following.

 

I have a calculated column (BundledSKU) that evaluates TRUE/FALSE if the invoice record SKU is a SKU in [Bundled SKU Matrix]. Then I can use that as a criteria in a Calculate(Firstnonblank()) to identify the relevant bundle sku name.

 

Can this be streamlined or is there a better way?

 

BundledQty = (LOOKUPVALUE('Bundled SKU Matrix'[Qty],'Bundled SKU Matrix'[SKU],CALCULATE(FIRSTNONBLANK(invoicedetails[SKU],TRUE()),filter(invoicedetails,invoicedetails[BundleSKU]=TRUE() && invoicedetails[_invoiceid_value] = EARLIER(invoicedetails[_invoiceid_value]))),'Bundled SKU Matrix'[BundleSKU],invoicedetails[SKU])+0) * CALCULATE(FIRSTNONBLANK(invoicedetails[Quantity],TRUE()),filter(invoicedetails,invoicedetails[BundleSKU]=TRUE() && invoicedetails[_invoiceid_value] = EARLIER(invoicedetails[_invoiceid_value])))+0

 

 

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.

Top Solution Authors