Forum Discussion
Text.AfterDelimiter in transformation step did not change column type
- 1 year ago
What seems to be happening is that the data is transformed to a number, but the type of the column remains as text, so the numbers are treated as text. I can't tell you why it's doing this as it seems wrong.
Even if you do this
each Number.From(Text.AfterDelimiter(_, "k"))the column is still an ANY type (ABC 123) rather than number. Seems that PQ is treating the column type and the data in the column as different types. A bug? Or by design? I don't know why you'd have a column of one type and the data within treated as a different type.
Phil
- 1 year ago
Thank you for your reply @PhilipTreacy.
I have done the work around and it seems to be working for now.
Since we now know that, output from Text.AfterDelimiter(_, "k") will always be ANY, I nested it with Number.FromText and specify column type as Number.
= Table.TransformColumns(#"Unpivoted Columns", {{"FcstWK", each Number.FromText(Text.AfterDelimiter(_, "k")), type number}})However, I am still unsure why Table.TransformColumns is not converting it to number.
What seems to be happening is that the data is transformed to a number, but the type of the column remains as text, so the numbers are treated as text. I can't tell you why it's doing this as it seems wrong.
Even if you do this
each Number.From(Text.AfterDelimiter(_, "k"))
the column is still an ANY type (ABC 123) rather than number. Seems that PQ is treating the column type and the data in the column as different types. A bug? Or by design? I don't know why you'd have a column of one type and the data within treated as a different type.
Phil
- Gauravshahin1 year agoFrequent Visitor
Thank you for your reply @PhilipTreacy.
I have done the work around and it seems to be working for now.
Since we now know that, output from Text.AfterDelimiter(_, "k") will always be ANY, I nested it with Number.FromText and specify column type as Number.
= Table.TransformColumns(#"Unpivoted Columns", {{"FcstWK", each Number.FromText(Text.AfterDelimiter(_, "k")), type number}})However, I am still unsure why Table.TransformColumns is not converting it to number.