Forum Discussion
Preparing a pricelist - products and assemblies
- 7 months ago
This is a great example of where the challenge is less about the formula itself and more about how the model is structured.
For assemblies, what you’re really trying to do is iterate through each component in the assembly, multiply the quantity by the product price, and then sum everything up.
In DAX terms, that usually means using something like SUMX over your assembly configuration table, where you can pull in the related product price for each component.
Conceptually, it would look something like:
Loop through each row in the assembly configuration
For each component:
get the quantity
get the related product price
Multiply and sumSo your assembly part of the measure would follow that pattern:
Assembly Price =
SUMX(
'Assembly configurations',
'Assembly configurations'[Quantity] *
RELATED('Basic product pricelist'[New Price])
)Then your SWITCH logic can call this when Type = "Assembly".
If this isn’t returning results yet, it’s usually a sign that the relationship path between:
assembly → configuration → product → price
isn’t fully connected or active in the model.
One thing I’d double check is whether your model allows the filter from the selected assembly to correctly flow into the configuration table and then back to the product price. That relationship flow is what makes the calculation work.
I’ve run into similar setups where the DAX looked right, but the real issue was the relationship direction or missing link in the chain.
Hi Fistachpl
_price :=
VAR _type =
SELECTEDVALUE('dim Products and Assemblies'[Type])
RETURN
SWITCH(
TRUE(),
-- Basic product
_type = "Product",
MAX('Basic product pricelist'[New Price]),
-- Assembly
_type = "Assembly",
SUMX(
'Assembly configurations',
'Assembly configurations'[Quantity] *
CALCULATE(
MAX('Basic product pricelist'[New Price]),
TREATAS(
VALUES('Assembly configurations'[Component Product]),
'Basic product pricelist'[Product]
)
)
)
)
try this