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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
FR_PBI
Frequent Visitor

Need Correct DAX for an excel formula with "IF"

Hi All, can you help me with this "If" DAX?

I couldn't solve the problem.

 

FR_PBI_0-1695020923906.png

 

In a generated Excel table, In column N, I have Cost which should be a multiplication of "Net Quantity" and "Product/item Cost". However, In the green highlighted cells the cost is missing. So, I need a DAX to solve this.

 

Currently, I created a column in the Excel file - Column "O" (you can see the Excel formula in the above screenshot). But I want to add a DAX for the same formula I put in column "O" which is like the below:

Cost = If "Net Quantity" * "Product/item Cost" = 0, then "Net sales" * 56% or else "Net Quantity" * "Product/item Cost".

Here I use 56% as an average cost % against sales for all other products. (if any Dax can be created for this please help me on that too If possible)

 

I need the DAX to calculate the Cost for each row individually.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @FR_PBI ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a calculated column.

Cost = IF([Net Quantity]*[Product/item Cost]=0,[Net Sales]*0.56,[Net Quantity]*[Product/item Cost])

(3) Then the result is as follows.

vtangjiemsft_0-1695174250427.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examplesIt is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
FR_PBI
Frequent Visitor

Hi, @Anonymous  Thank you! I have added a column with this formula. 

FR_PBI_1-1695302573054.png

 

FR_PBI_2-1695302605123.png

 

 

As you can see, in the orange highlighted column (earlier cost column with blank/zero values ) now has the value in the yellow highlighted column.  Now I have a new added column in the table. 

However, I have a question, if I don't want to add a column in the table and only want to create a measure with a DAX what can I do?

Best Regards,

 

Anonymous
Not applicable

Hi @FR_PBI ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a calculated column.

Cost = IF([Net Quantity]*[Product/item Cost]=0,[Net Sales]*0.56,[Net Quantity]*[Product/item Cost])

(3) Then the result is as follows.

vtangjiemsft_0-1695174250427.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examplesIt is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors