# Please Help - Using "if" function to categorize data by whether it's above or below a specified value

• ### Question

• I have a list of every state and it's combined state/local tax rate. I need to sort these values based on which ones are over and under 5%, and then count how many are in each category. I'm trying to use the function if([COMBINED RATE]<.05,"low","high") to sort them by which values are under 5% and which are over. COMBINED RATE is the table in which the tax rates are listed. I keep getting the error "RightParen expected".

I've spent a long time reading my textbook, browsing forums, and emailing my professor and I've had no luck so far. If anyone can help me correct this issue with the formula and give me some guidance on how to count the number in each category it would be greatly appreciated. I can provide images if needed. Thanks!
Wednesday, December 4, 2019 5:52 AM

• Hi

Your If...Then...Else is written as in Excel: if([COMBINED RATE]<.05,"low","high"). In Power Query M you have to use syntax if condition then value/what_to_do if true else value/what_to_do if false

So your test should be: if ([COMBINED RATE] <.05) then "low" else "high"

Example of if...then...else  at the bottom of Expressions, values, and let expression

Wednesday, December 4, 2019 6:29 AM

### All replies

• Hi

Your If...Then...Else is written as in Excel: if([COMBINED RATE]<.05,"low","high"). In Power Query M you have to use syntax if condition then value/what_to_do if true else value/what_to_do if false

So your test should be: if ([COMBINED RATE] <.05) then "low" else "high"

Example of if...then...else  at the bottom of Expressions, values, and let expression

Wednesday, December 4, 2019 6:29 AM
• That worked perfectly. Thank you!
Wednesday, December 4, 2019 6:08 PM
• You're welcome. Please Mark as answer => Can help others - Thanks
Wednesday, December 4, 2019 6:16 PM