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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

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 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Well, you could make your life easy and just do this in a calculated column, 

( [selling_price] - [ITEM_COST_INCL_VAT] ) * [QUANITY_ORDERED]

However, I expect that you don't just have that one table in your model but multiple tables. If that is indeed the case, then, Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@Anonymous Well, you could make your life easy and just do this in a calculated column, 

( [selling_price] - [ITEM_COST_INCL_VAT] ) * [QUANITY_ORDERED]

However, I expect that you don't just have that one table in your model but multiple tables. If that is indeed the case, then, Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.