0
votes

I'm trying to add a Custom Column using the following m query language:

= if AccountType {{"I","E"}} then "IS" else "BS"

Herewith is a screenshot of the Custom Column:

Custom Column

As you notice, no syntax errors are found, however, when I click OK, I get the following Error:

Expression.Error: We cannot apply an index of type List. Details: Value=[Table] Index=[List]

I've looked at numerous websites, but couldn't find a solution to this. The closest match is this, but the answer is not very clear.

Please help.

2
Can you show some details of "I" and "E"?mkRabbani
The Column Value will either be "I" or "E" or "N", which is why I'm adding the Custom Column to distinguish when it's "I" or "E", then it's Income Statement, otherwise it's Balance Sheet... If you need more context, please let me know :)Birel

2 Answers

1
votes

Does this work

= if [AccountType] = "I" or [AccountType] = "E" then "IS" else "BS"
0
votes

You could also use if List.Contains({"I","E"}, [AccountType]) then "IE" else "BS"; or if the list is actually from a column, you can replace the {"I","E"} with a reference to the list's column, like in if List.Contains(tablename[columnname], [AccountType]) then "IE" else "BS"; or if the list is an actual list, you can replace the {"I","E"} with a reference to the actual list, like in if List.Contains(listname) then "IE" else "BS".