Forum Discussion
rank index custom columns query
- 6 years ago
Hi, JOHN14400
let Source = Table.FromRecords(Json.Document(Binary.Decompress(Binary.FromText("i65W8kvMTVWIKTUwSDTASilZKTn6OLkGhUC4uEilWh2izAryd3cNoo5R7p543UWsMcH+AR6ertRxUoiHa5BrME7DiDXG1zGIWi7ycnX0w28SaeYFOIb6EGdeLAA=",BinaryEncoding.Base64),Compression.Deflate))), addidx = Table.AddIndexColumn(Source,"Index"), result = Table.TransformColumns(addidx, {"Index", each Number.Mod(_, 3)+1, type number}) in resultIf my code solves your problem, mark it as a solution
- 6 years ago
According to the description of your problem, modify the code as follows. But I see that you are expecting the result to be a change every three lines, in which case the loop number doesn't need to be added. Just start directly with the split step.
let Source = Table.FromRecords(Json.Document(Binary.Decompress(Binary.FromText("i65W8kvMTVWyUnL0cXINCokpNTBINMBFKtXqwNUH+bu7BhGv3N0Tr/nISoP9Azw8XYk3OsTDNcg1GKcGZKW+jkGkmOzl6uiHXzWmngDHUB/i9MQCAA==",BinaryEncoding.Base64),Compression.Deflate))), addidx = Table.AddIndexColumn(Source,"Index"), mod = Table.TransformColumns(addidx, {"Index", each Number.Mod(_, 3)+1, type number}), split = Table.Split(mod, 3), trans = List.Transform(split, each Table.PromoteHeaders(Table.Transpose(Table.ReorderColumns(_,{"Index", "Name"})))), result = Table.Combine(trans) in resultBut that would require a code change, so you'll try with code above
According to the description of your problem, modify the code as follows. But I see that you are expecting the result to be a change every three lines, in which case the loop number doesn't need to be added. Just start directly with the split step.
let
Source = Table.FromRecords(Json.Document(Binary.Decompress(Binary.FromText("i65W8kvMTVWyUnL0cXINCokpNTBINMBFKtXqwNUH+bu7BhGv3N0Tr/nISoP9Azw8XYk3OsTDNcg1GKcGZKW+jkGkmOzl6uiHXzWmngDHUB/i9MQCAA==",BinaryEncoding.Base64),Compression.Deflate))),
addidx = Table.AddIndexColumn(Source,"Index"),
mod = Table.TransformColumns(addidx, {"Index", each Number.Mod(_, 3)+1, type number}),
split = Table.Split(mod, 3),
trans = List.Transform(split, each Table.PromoteHeaders(Table.Transpose(Table.ReorderColumns(_,{"Index", "Name"})))),
result = Table.Combine(trans)
in
result
But that would require a code change, so you'll try with code above
Hello ziying 35
Thanks for yours fasters answers it works !