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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Oros
Post Prodigy
Post Prodigy

Conditional measure to calculate

Hello,

 

I am trying to add a measure based on condition.  

 

If the Weight/Box=Default then the Total Boxes Ordered = Order

If the Weight/Box is NOT DEFAULT, then the Total Boxes Ordered = Order divided by Weight per Box.

 

Oros_0-1623078153598.png

Thanks.

 

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @Oros ,

 

if you want to do it in Power Query then add a "Custom Color" and add the following formula:

if [Weight_Box] = "Default" then [Order] else [Order] / [Weight_Box]

selimovd_0-1623078681882.png

 

If you want to solve that in the data model as calculated column try the following formula:

Total Boxes Ordered =
IF(
    myTable[Weight_Box] = "Default",
    myTable[Order],
    DIVIDE(
        myTable[Order],
        myTable[Weight_Box]
    )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

13 REPLIES 13
parry2k
Super User
Super User

@Oros something is not right, you need to share pbix file to look into it otherwise something like this simple shouldn't take this long.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Oros can you share your expression? I asked this previously, if you cannot follow a simple request, not sure how to help?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k ,

 

Sorry about that.  I used the same expression that you recommended. Here is what I entered:

 

Also, I organized and added a column named DEFAULT to hopefully make it clearer.  Thanks.

 

Oros_1-1623085955484.png

 

 

parry2k
Super User
Super User

@Oros are you adding a column or a measure? Can you share your DAX expression? And also can you paste the text instead of these tiny images.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k ,

 

I am adding a column.  I do not mind if the solution can be for a measure.  Thanks.

 

Here is the error:

 

DAX comparison operations do not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

parry2k
Super User
Super User

@Oros try this in DAX using calculated columns

 

Total Boxes Ordered = 
IF ( YourTable[Weight/Box] = "Default", YourTable[Order], DIVIDE ( YourTable[Order], VALUE ( YourTable[Weight/Box] ) ) 

 

The reason you want to use VALUE in divide because your Weight/Box column is of Text type and we need to convert it into value. Read mode about value function here VALUE function (DAX) - DAX | Microsoft Docs

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k,

 

Thank you for your reply.  It seems that it does not work.  Maybe I am missing something?

 

Oros_1-1623080256670.png

 

 

selimovd
Super User
Super User

Hey @Oros ,

 

if you want to do it in Power Query then add a "Custom Color" and add the following formula:

if [Weight_Box] = "Default" then [Order] else [Order] / [Weight_Box]

selimovd_0-1623078681882.png

 

If you want to solve that in the data model as calculated column try the following formula:

Total Boxes Ordered =
IF(
    myTable[Weight_Box] = "Default",
    myTable[Order],
    DIVIDE(
        myTable[Order],
        myTable[Weight_Box]
    )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi @selimovd ,

 

The custom column solution seems to be dividing everything and not seeing the 'DEFAULT' (or TRUE).

 

The calculated column in the data model also did not work.  Maybe I am missing something?

Oros_0-1623080103370.png

 

Thanks again.

 

Hey @Oros ,

 

can you send an actual screenshot from PowerQuery or Power BI and not from Excel?

Or can you share your file? This would be the best option.

 

Best regards

Denis

Hi @selimovd 

 

I organized and added a column called DEFAULT, hopefully to make it clear.

 

Oros_0-1623085497143.png

Thanks.

@Oros This is not a screenshot from Power BI or Power Query. Like this I can't help you...

Hi @selimovd 

 

That is NOT a Power Bi screenshot.  That is a change from the original post.

 

Thanks.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors