Forum Discussion
Error with < query
Hi,
I'm trying to add a column to a table by which looks at value in another column and adds "Yes" or "No" depending on if it's less that 0.
The line is
= Table.AddColumn(#"Grouped Rows", "Required Rework", each if [Min Vote] < 0 then "Yes" else "No")
where the content of [Min vote] is a number and the column type if also a number. Teh Min Vote column is created in a previous Table.Group aggregate using {"Min Vote", each List.Min([Vote Only]), type number}.
However I get an error
Expression.Error: We cannot apply operator < to types Number and Text.
Details:
Operator=<
Left=0
Right=10
Any idea why this is giving me an error?
4 Replies
- HotChilliCommunity Champion
One of my stock answers on the forum now is : Try using the Column quality, distribution, profile features from the View menu to look at your data.
The M language looks fine to me.
The error message thinks there is a text value somewhere in the column
- AnonymousNot applicable
Thanks, that's the strange thing, I can't find any entry which is text, and the whole column type shows as number in the column header.
- v-juanli-msftCommunity Support
Hi Anonymous
It works on my side.
Could you show me your code in Advanced editor?
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTJUitWBsIzArCQgS9cYzEyGC6aABE2VYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [dsd = _t, #"Vote Only" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"dsd", type text}, {"Vote Only", Int64.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"dsd"}, {{"Min Vote", each List.Min([Vote Only]), type number}}), n=Table.AddColumn(#"Grouped Rows", "Required Rework", each if [Min Vote] < 0 then "Yes" else "No") in nBest Regards
MaggieCommunity Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - ImkeFCommunity Champion
Please try this:
Table.AddColumn(#"Grouped Rows", "Required Rework", each if Number.From( [Min Vote] ) < 0 then "Yes" else "No")