Forum Discussion
DAX if statement syntax error
- 7 years ago
Anonymous Please note "Power Query" expressions are case sensitive. "IF" not same as "if", please correct the all keywords in your expression.
Anonymous Please try this..
=IF (CONTAINS(TableName,[Content],"SHOWS"),"SHOWS",IF ([Content] IN {"DRY","WATER"},"DRY","HC"))Note - CONTAINS will return TRUE if there is any row in the table that contains SHOWS in the Content field. Not sure whethere you want that behaviour or looking for searching in each row then try this
IF(SEARCH("SHOWS",[Content],1,0)>0,"SHOWS",IF(Test140[Content] IN {"DRY","WATER"},"DRY","HC"))
- Anonymous7 years agoNot applicable
I've tried both... and although there are no syntax error detected I still getr the message "Expression.Error: The name 'IF' wasn't recognised....."
Do I need to specify the Table name in the formula, seeing as this is a given
- LivioLanzo7 years agoSolution Sage
Anonymous
looks like you're using Power Query and not DAX
try this:
= if Text.Contains([Conent],"SHOWS") then "SHOWS" else if List.Contains({"DRY","WATER"},[Content]) then "DRY" else "HC"
- Anonymous7 years agoNot applicable
Yes I'm working in PowerQuery... (I thought this was the same)
I've tried several approaches nothing seems to work..
My Column conatins 12 unique types of entry (text), all those rows containing the words "SHOWS" should be returned as "SHOWS". Entries with "DRY" or "WATER" should return "DRY", all other entries should Return the value "HC"
Keep getting Syntax errors I don't understand... is the syntax case sensative, when should I use IF.. Then and Else rather than commas
(This is an Oil industry problem... in case you were wondering)