The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Thanks.
Solved! Go to Solution.
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]
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]
)
)
@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.
@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 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.
@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?
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]
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]
)
)
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?
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
@Oros This is not a screenshot from Power BI or Power Query. Like this I can't help you...