Forum Discussion
Conditional Index M Language - Power Query
- 5 years ago
Hello DaxBoi
are you sure that you need some graphical output like your second table? Meaning that your headers are repeating throughout your data? Or should it look like this?
if yes, here the approach to get this result
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8khNTMnMS1cwVNJRMjDUByIjAyMYxwjCidWJVnIECoGEjcA8JyDLGIhNwDxnIMsUiM3APJiJRiSZ6IxiIswMYwJmuCDMiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Column1"}, {{"AllRows", each Table.TransformColumnNames(Table.PromoteHeaders(_), (x)=> if Text.StartsWith(x,"Heading") then "Value" else x)}}, GroupKind.Local, (x,y)=> if Text.StartsWith(y[Column1], "Headin") then 1 else 0), #"Expanded AllRows" = Table.ExpandTableColumn(#"Grouped Rows", "AllRows", {"Value", "01/01/2021", "01/02/2021"}, {"Value", "01/01/2021", "01/02/2021"}) in #"Expanded AllRows"Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello DaxBoi
are you sure that you need some graphical output like your second table? Meaning that your headers are repeating throughout your data? Or should it look like this?
if yes, here the approach to get this result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8khNTMnMS1cwVNJRMjDUByIjAyMYxwjCidWJVnIECoGEjcA8JyDLGIhNwDxnIMsUiM3APJiJRiSZ6IxiIswMYwJmuCDMiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Column1"}, {{"AllRows", each Table.TransformColumnNames(Table.PromoteHeaders(_), (x)=> if Text.StartsWith(x,"Heading") then "Value" else x)}}, GroupKind.Local, (x,y)=> if Text.StartsWith(y[Column1], "Headin") then 1 else 0),
#"Expanded AllRows" = Table.ExpandTableColumn(#"Grouped Rows", "AllRows", {"Value", "01/01/2021", "01/02/2021"}, {"Value", "01/01/2021", "01/02/2021"})
in
#"Expanded AllRows"
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy