Last active
November 18, 2019 20:06
-
-
Save ImkeF/1dfcac25caa1fb5ec2af831fec8b15bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(ExpandedJson as table, optional adjustDotDel as number) => | |
let | |
AdjustSkip = if adjustDotDel = null then 1 else adjustDotDel, | |
Source = ExpandedJson, | |
NameKey = Table.AddColumn(Source, "NameKey", each Text.Combine(List.Transform([Dots], (x) => Text.From(Record.Field(_,x))), " | "), type text), | |
Item = Table.AddColumn(NameKey, "Item", each Text.BeforeDelimiter([Sort], ".", {0, RelativePosition.FromEnd}), type text), | |
#"Extracted Text After Delimiter" = Table.TransformColumns(Item, {{"SortBy", each Text.BeforeDelimiter(_, ".", AdjustSkip), type text}}), | |
#"Removed Other Columns" = Table.SelectColumns(#"Extracted Text After Delimiter",{"Value", "NameKey", "Item", "SortBy"}), | |
#"Pivoted Column" = Table.Pivot(#"Removed Other Columns", List.Distinct(#"Removed Other Columns"[NameKey]), "NameKey", "Value") | |
in | |
#"Pivoted Column" , | |
documentation = [ | |
Documentation.Name = " Table.FlattenJSON ", | |
Documentation.Description = " Flattens expanded JSON table ", | |
Documentation.LongDescription = " Flattens expanded JSON table ", | |
Documentation.Category = " Table ", | |
Documentation.Source = " www.TheBIccountant.com ", | |
Documentation.Version = " 1.0 ", | |
Documentation.Author = " Imke Feldmann: www.TheBIccountant.com. . ", | |
Documentation.Examples = {[Description = " ", | |
Code = " ", | |
Result = " "]}] | |
in | |
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment