Forum Discussion
Column split by conditon
- 7 years ago
Anonymous -
Are you meaning that you have so many conditions for Text.StartsWith = "P" || "QM" || etc.?
If so, then you should include those requirements in your question.
Otherwise, you just need to add the logic from the last statment
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([#"As-is"], "P") then Text.RemoveRange([#"As-is"],7) else if Text.StartsWith([#"As-is"],"QM") then Text.RemoveRange([#"As-is"],7) else [#"As-is"])
Anonymous -
This seems to work:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnB0cg4wMHRUitWJVnIO9vcN8TcwAXMCAgKDIgwMfcGcQF8DCwuLEIgyxxAf5xAfA0Ol2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"As-is" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"As-is", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([#"As-is"], "P") then Text.RemoveRange([#"As-is"],7) else if Text.StartsWith([#"As-is"],"QM") then Text.RemoveRange([#"As-is"],7) else [#"As-is"])
in
#"Added Custom"- Anonymous7 years agoNot applicable
ChrisMendoza i have many such values below is the sample
- ChrisMendoza7 years agoResident Rockstar
Anonymous -
Are you meaning that you have so many conditions for Text.StartsWith = "P" || "QM" || etc.?
If so, then you should include those requirements in your question.
Otherwise, you just need to add the logic from the last statment
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([#"As-is"], "P") then Text.RemoveRange([#"As-is"],7) else if Text.StartsWith([#"As-is"],"QM") then Text.RemoveRange([#"As-is"],7) else [#"As-is"])
- dax7 years agoCommunity Support
Hi ajitk15,
You could follow above ChrisMendoza's suggestions or simplify code by "Or " condition like below
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnB0cg4wMHRUitWJVnIO9vcN8TcwAXMCAgKDIgwMfcGcQF8DCwuLEIgyxxAf5xAfA0Ol2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"As-is" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"As-is", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([#"As-is"], "P") or Text.StartsWith([#"As-is"],"QM") then Text.RemoveRange([#"As-is"],7) else [#"As-is"]) in #"Added Custom"Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.