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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
gdlrsilv3
Regular Visitor

question about complicated data transformation

Hi,

 

I have a question on data transformation, I have the following scenario, in my imported invoices information I have part numbers that are multipack (a box with N single products) and also part numbers that are single types when they are sold individually.

 

Sales table

InvoiceNumitem_codeqty
1Pack-118031
20180340

 

Item table

item_codeDescriptionitem_type
Pack-11803Eight Pack Orange Juice 355mlMultipack
01803Orange Juice 355mlSingle
00010carton boxpurchased

 

 

also I have a table BOM, that tells how the multipack part number is built, in this case it is telling me that multipack part number (Pack-11803) will have 8 single items part number 01803.

 

ParentItemqtyChildItem
Pack-11803801803
Pack-11803100010

 

 

 

how could I transform the data to replace the multipack part number with the single item part numbers and the right quantity?. At the end of the transformation I should have:

 

desired Sales table

InvoiceNumitem_codeqty
1018038
20180340

 

 

any body who could point me to the right direction? I'm new in Power BI

 

thanks for any help, regards,

 

gdlrsilv3_0-1634156639608.png

 

here is the link to the PBIX

https://1drv.ms/f/s!AM_4N0ZUNxX-gQs 

1 ACCEPTED SOLUTION

Hi  @gdlrsilv3 ,

 

First create a column in Bom:

Invoice number = LOOKUPVALUE('Sales'[InvoiceNum],'Sales'[item_code],'BOM'[ParentItem],blank())

And create a table as below:

Union = UNION('Sales',SELECTCOLUMNS('BOM',"InvoiceNum",'BOM'[Invoice number],"item_code",'BOM'[ChildItem],"qty",'BOM'[qty]))

Then create a measure:

Measure =
VAR _type =
    CALCULATETABLE (
        VALUES ( 'Item'[item_code] ),
        FILTER ( ALL ( 'Item' ), 'Item'[item_type] = "Single" )
    )
RETURN
    IF ( MAX ( 'Union'[item_code] ) IN _type, 1, BLANK () )

Put measure in the filter pane and select measure is 1;

And you will see:

vkellymsft_0-1634620261172.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

 

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

It looks like you are ignoring the second ChildItem, 00010. Why do you pick 8 instead of 1 or 8+1?

I won't consider item 00010 because it is a carton, only items with item_type = 'Single' will be considered.

Hi  @gdlrsilv3 ,

 

First create a column in Bom:

Invoice number = LOOKUPVALUE('Sales'[InvoiceNum],'Sales'[item_code],'BOM'[ParentItem],blank())

And create a table as below:

Union = UNION('Sales',SELECTCOLUMNS('BOM',"InvoiceNum",'BOM'[Invoice number],"item_code",'BOM'[ChildItem],"qty",'BOM'[qty]))

Then create a measure:

Measure =
VAR _type =
    CALCULATETABLE (
        VALUES ( 'Item'[item_code] ),
        FILTER ( ALL ( 'Item' ), 'Item'[item_type] = "Single" )
    )
RETURN
    IF ( MAX ( 'Union'[item_code] ) IN _type, 1, BLANK () )

Put measure in the filter pane and select measure is 1;

And you will see:

vkellymsft_0-1634620261172.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.