Forum Discussion
Error using if condition
hi,
i am getting the below error, can you help me?
6 Replies
- edhansCommunity Champion
Your && is causing the nesting to not work right. Can you post the text of the measure vs a screenshot? I'm not going to key that in to try and replicate the syntax issue and then fix it.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum - AnonymousNot applicable
Hi,
Please try this Calculated Column
Column =
SWITCH (
TRUE (),
Procurementdata[Transaction Amount] >= 25000001, ">$25M",
Procurementdata[Transaction Amount] >= 100000000
&& Procurementdata[Transaction Amount] <= 25000000, "$10M - $25M",
Procurementdata[Transaction Amount] < 10000000, "<$10M"
)Regards,
Harsh NathaniDid I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
- v-yingjlCommunity Support
Hi vjnvinod ,
The ‘&&’ operator should not be used between two if() statements, just modify like this:
Column = IF( 'Procurementdata'[Transaction Amount] >= 25000000, ">$25M", IF( 'Procurementdata'[Transaction Amount] >= 10000000 && 'Procurementdata'[Transaction Amount] < 25000000 , "$10M-$25M", "<$10M" ) )Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- vjnvinodImpactful Individual
thank you it actually worked but its not coming in order
is it possible to show that in the below order?
.$25M at top
$10M-$25M
<$10M
- v-yingjlCommunity Support
Hi vjnvinod ,
Based on your picture, seems to order it in a slicer, right?
Could not achieve it directly but you can create another column to mark each tag like a rank:
Column 2 = IF ( 'Procurementdata'[Column] = ">$25M", 1, IF ( 'Procurementdata'[Column] = "$10M-$25M", 2, 3 ) )Click the three dots and choose sort by column2 and sort asc
Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- ryan_mayuSuper User
if(condition1&&condition2), you need to remove the if I highlighted in the below screenshot.
If you want to sort in order, you create a new table, column 1 order :1,2,3; column two values(like(>$25M). Create relationship with the fact table and order table.
Or you can add the order number in the formula. "1. >$25M"