Forum Discussion
Maltaparis
1 year agoFrequent Visitor
Need help to fix my code
Dear all, I need your help I am getting crazy, in Powerquery, I created a calculated column but it doesnt worK All the column names are correct It keep stating there is a syntax error with "and" ...
- 1 year ago
There is no need for parentheses here after if .
But you are missing the reference to the outer scope.
each [MAT] = [MAT]will always evaluate to true and
and [Date] = [DateMax]doesn't know where to find [Date].
Show the entire code for that step if you want further help.
ZhangKun
1 year agoSuper User
The reason for the error is that [Date] in Table.SelectRows does not exist in the MS table.
There is also a semantic error where the expression "[MAT] = [MAT]" is always true.
Take some of them as examples (please modify according to the actual content):
//Table.RowCount(Table.SelectRows(MS, each [MAT] = [MAT] and [Date] = [DateMax]))
Table.RowCount(Table.SelectRows(MS, (r) => x[MAT] = [MAT] and x[Date] = [DateMax]))A prefix with "r" indicates that it is from an MS table, and a prefix with no "r" indicates that it is from an external table (a table to which columns are added).