Forum Discussion
nazdravanul
8 years agoFrequent Visitor
Create conditional index column based on row values - at Querry level
Existing column Required ouptut on custom column BAB 0 BAB 1 BAB 2 CIC 0 CIC 1 CIC ...
- 8 years ago
Hi nazdravanul,
I copied and pasted your data in my model ( I called Data), and this is the Power Query code ( with Advanced Editor) :
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnJ0UorVwaSdPZ2Jol1cXBF0LAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Test = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Test", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Test"}, {{"Count", each Table.AddIndexColumn(_,"Index",0,1), type table}}), #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Index"}, {"Index"}) in #"Expanded Count"So you can replace the source and then copy and paste the rest....
Ninter...
Interkoubess
8 years agoSolution Sage
Hi nazdravanul,
I copied and pasted your data in my model ( I called Data), and this is the Power Query code ( with Advanced Editor) :
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnJ0UorVwaSdPZ2Jol1cXBF0LAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Test = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Test", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Test"}, {{"Count", each Table.AddIndexColumn(_,"Index",0,1), type table}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Index"}, {"Index"})
in
#"Expanded Count"So you can replace the source and then copy and paste the rest....
Ninter...
nazdravanul
8 years agoFrequent Visitor
Thank you very much - with a bit of tinkering, in order to adjust it to my existing querry, this worked like a charm! :)