Forum Discussion
Converting data from Kits to components
- 6 years ago
Hi David,
I modified a bit the solution to take into account that there is a single master table, and that kits can be identified based on the column Tipo.
You can download the updated solution from here.
And here is the new DAX formula:
Units sold = var currentProduct = [Product] VAR productIsKit= LOOKUPVALUE('Masterdata'[Tipo],'Masterdata'[Product],currentProduct) = "Kit" VAR productSales = LOOKUPVALUE(Sales[Units sold],Sales[Item],[Product],0) VAR productSalesViaKit = SUMX( 'Masterdata', IF([Item]=currentProduct, [Qty per kit]*LOOKUPVALUE(Sales[Units sold],Sales[Item],[Product],0) ) ) RETURN IF(productIsKit, 0, productSales+productSalesViaKit)It's very similar to before. The only main change is how to check whether the product is a kit.
Now the variable productIsKit looks at the 'Tipo' column: if the Tipo column is equal to kit, then it considers the product to be a kit.
Hopefully, this matches all of your requirements
Let me know if anything is unclear
LC
- 6 years ago
Hi David,
I updated your file to include the calculation.
You can download it from here.
I hope that this is what you are looking for. If you need more help, do not hesitate to ask.
LC
Interested in Power BI and DAX templates? Check out my blog at www.finance-bi.com
Hi David,
I should have some time tomorrow to look at it and then get back to you.
And no worries, I will make sure we find a solution to your formula issues.
Regards
LC
Hi David,
I updated your file to include the calculation.
You can download it from here.
I hope that this is what you are looking for. If you need more help, do not hesitate to ask.
LC
Interested in Power BI and DAX templates? Check out my blog at www.finance-bi.com
- Jdsarmientoc6 years agoFrequent Visitor
Dear lc_finance
Im exploring your solution and comparinb vs the result i get when doing the consolidation of kits into items manually but just noted something:
Take for example item 178690. This item is NOT a kit nor a component of a kit. This is a regular item that is sold individually therefore this should have the same amount on the original sales table and the calculated one. However im noting that this changes.
This is using the original Pedidos table:
Using Pedidos by item calculated table
And this is using the Pedidos by item calculated table:
Using original Pedidos table
As you can see some months are the same as it should but some months they are different.
Finally the last thing i would like to ask your help with is with the fields Inv (stock) and BO (backorder). I would like to also "explode" them by component item, just like the sales. This one is not needed month by month, just the total of current Inv (stock) and total current BO (backorder) per item. Since this is similar to what you did with Pedido (sales) i will try to emulate it but would love your help in case i cant.
Best regards!
- lc_finance6 years agoSolution Sage
- lc_finance6 years agoSolution Sage
Hi Jdsarmientoc ,
I apologize for the time it took getting back to you, I just got married this week.
Anyway, you can download my updated solution from here.
The units sold formula needed an update. Here is the new version of the formula:
Units sold = var currentItem = [Item] var currentDate = [Fecha] VAR itemIsKit= LOOKUPVALUE('Maestro items'[Maestro Kits.Tipo],'Maestro items'[Item],currentItem) = "Kit" VAR itemDirectSales = CALCULATE(SUM('Pedidos'[Pedido]),'Pedidos'[Item]=currentItem,'Pedidos'[Fecha]=currentDate) VAR itemSalesViaKit = SUMX( 'Maestro Kits', IF([Item]=currentItem, var currentKit = [Kit] RETURN [Cantidad x kit]*CALCULATE(SUM('Pedidos'[Pedido]),ALL(),'Pedidos'[Item]=currentKit,'Pedidos'[Fecha]=currentDate) ) ) RETURN IF(itemIsKit, 0, itemDirectSales+itemSalesViaKit)I tried it on the example you provided and it works well now.
Is this what you are looking for?
For the explosion of stock and back-order, yes you can try to emulate it and get back to me if any issues.
Regards,
LC
Interested in Power BI and DAX tutorials? Check out my blog at www.finance-bi.com
- Jdsarmientoc6 years agoFrequent Visitor
Hello lc_finance
First of all contratulations on getting married! Wish you the best.
Your solution works great now and i also wanted to share an alternate very noob-friendly solution that i came up with using not DAX but the query editor instead.
I created a new table merging Pedidos and Maestro Kits and expanding Item and Qty per kit. The query editor code looks like this:
let
Source = Table.NestedJoin(Pedidos, {"Item"}, #"Maestro Kits", {"Kit"}, "Maestro Kits", JoinKind.LeftOuter),
#"Expanded Maestro Kits" = Table.ExpandTableColumn(Source, "Maestro Kits", {"Item", "Cantidad x kit"}, {"Maestro Kits.Item", "Maestro Kits.Cantidad x kit"})
in
#"Expanded Maestro Kits"That way i get something like this:
In red for example is what used to be a single line for item 188066 of 4 units.
Then in the model i add 2 columns for this table, one for Qty and one for Item component, as follows:
Qty = if([Maestro Kits.Cantidad x kit]=BLANK();[Pedido];[Pedido]*[Maestro Kits.Cantidad x kit])Item comp = if([Maestro Kits.Cantidad x kit]=BLANK();[Item];[Maestro Kits.Item])That way if the expanded field on the merge is blank it means it is an item that is NOT part of a kit so it uses de original SKU and Qty, but if it is not blank that means it is part of a kit and calculates the QTY and replaces the KIT SKU with the component SKU.
Best regards and thanks a lot for bearing with me!