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
lc_finance Thanks a lot for your response!
Please excuse my delay in responding but im on a business trip with very limited time so havent been able to try your solution.
However i'd like to ask something.
On my data model the "Kit" SKU is on the same master file as the components (Basically there is a single master table ITEMS that contains both components and Kits, with all the attributes like description, weight, etc). One of this attributes indicates if the SKU is a kit (doing with a merge during the query between the master of items and the following kits table - red circle on the picture- looking for all ITEMS on the items table and matching with KITS on the kits table, then expanding TIPO). The query formulas are like this:
= Table.NestedJoin(#"Removed Duplicates", {"Item"}, #"Maestro Kits", {"Kit"}, "Maestro Kits", JoinKind.LeftOuter)
= Table.ExpandTableColumn(#"Merged Queries", "Maestro Kits", {"Tipo"}, {"Maestro Kits.Tipo"})That way i have an attribute that indicates if the ITEM is a KIT or a component if this field is blank.
Finally on the table Pedidos (Sales) i add a calculated column to indicate if the sale is that item is a kit or not with the formula
Kit? = RELATED('Maestro items'[Maestro Kits.Tipo])From what i can understand on your proposed solution there should be a master table for components and a master table for Kits, or is this not the case?
Rest assured that i will try your solution asap and get back to you!
Thanks in advance,
David.
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