Forum Discussion
non23
2 years agoHelper I
Create a new column based on another column
Hi guys.
Is there a way to create a new column for this one? Below is an example of what we want to achieve.
Value is the original column.
Hi non23, check this:
Output
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjU0NDIw0NMzNbS0MDCwNrW0NANzLUFcpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]), Ad_NewColumn = Table.AddColumn(Source, "New Column", each [ a = Text.Split([Value], ";"), b = List.Transform(a, (x)=> Text.Split(x, "..")), c = List.Transform(b, (x)=> List.Generate( ()=> Number.From(x{0}), each _ <= Number.From(x{1}), each _ +100 ) ), d = List.Combine(c) ][d]), ExpandedNewColumn = Table.ExpandListColumn(Ad_NewColumn, "New Column") in ExpandedNewColumn
4 Replies
- dufoq3Community Champion
Hi non23, check this:
Output
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjU0NDIw0NMzNbS0MDCwNrW0NANzLUFcpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]), Ad_NewColumn = Table.AddColumn(Source, "New Column", each [ a = Text.Split([Value], ";"), b = List.Transform(a, (x)=> Text.Split(x, "..")), c = List.Transform(b, (x)=> List.Generate( ()=> Number.From(x{0}), each _ <= Number.From(x{1}), each _ +100 ) ), d = List.Combine(c) ][d]), ExpandedNewColumn = Table.ExpandListColumn(Ad_NewColumn, "New Column") in ExpandedNewColumn - wdx223_DanielCommunity Champion
NewStep= Table.ExpandListColumn(Table.AddColumn(YourTable,"NewValue",each Expression.Evaluate("{"&Text.Replace([Value],";",",")&"}")),"NewValue")