Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Subtraction Iteration + Multiplication in DAX

Hello

I'm facing a very newbie problem

I have this table:

 

Selling_PriceITEM_COST_INCL_VATQUANTITY_ORDERED
16.8999996216.9930
16.9500007616.9200
7.571200
1212.84580
16.9500007616.9870
2726.52190
17.6599998516.91420
7.571860
6.80000019171360
7.19000005771860
6.44999980971540
7.571860
7.4499998097820
Total: 157.85Total: 155.96Total: 14690

 

I'm doing this to subtract the Selling Price - Cost Price * Quantity Ordered for each row, but instead, my measure is summing everything..

 

 

Forecasted margin (selling price incl VAT - cost incl VAT) = 
VAR selling_price = SUMX(f,RELATED(dCatalog[selling_price]))
VAR cost_price_incl_vat = SUMX(f,[ITEM_COST_INCL_VAT])
VAR quantity_ordered = SUMX(f,[QUANTITY_ORDERED])
VAR margin_per_product = selling_price - cost_price_incl_vat
VAR result = margin_per_product * quantity_ordered
RETURN
result

 

 

Result that is showing my measure: 27764

Expected Result: 2800.10

 

How can I fix that?

 

 

Thanks

Diego

 

 

1 Reply