Forum Discussion

wolfy_'s avatar
wolfy_
Helper I
6 years ago
Solved

Create table from 6 steps in the same excel file

Hi guy's,   I'm trying to find a better way to perform what I'm doing at the moment.   I what to transform visualize data like this, from a excel file that is generated automatically by a system ...
  • MFelix's avatar
    6 years ago

    Hi wolfy_ ,

     

    Believe that the best option would be to use a matrix visualization and using the column Steep to make you calculation and filtering in measure or something.

     

    However if you only have one file what you need to do is some advance pivoting.

     

     

    Check the code below:

     

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jc8xD4IwEAXgv0KYSegdVFiNE2HQwY0wGNNN0Nj+/2AR8F0uUQcSrv3y7rXrUkqz9HAfw+UaXn+GcrPL2bCRQ5+95d575wc3ztaitcKySCWUpCWmsgELQ7SF6lph10pK0VVYFja+6+x8cH9kbo6/58WWz6XmD9oMj5tbaxZoC2EZ15foSlUT11ukVkUirZHWKhWbkgELw/qq9tQkxzbeYVXSVT8Qi5IuituT+VtvtojluJ8A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project ID" = _t, Steep = _t, #"Date started" = _t, #"Date Completed" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project ID", Int64.Type}, {"Steep", type text}, {"Date started", type date}, {"Date Completed", type date}}),
        #"Removed Columns1" = Table.RemoveColumns(#"Changed Type",{"Date Completed"}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Removed Columns1", {"Project ID", "Steep"}, "Attribute", "Value"),
        #"Removed Duplicates" = Table.Distinct(#"Unpivoted Columns"),
        #"Added Index" = Table.AddIndexColumn(#"Removed Duplicates", "Index", 0, 1, Int64.Type),
        #"Grouped Rows" = Table.Group(#"Added Index", {"Steep", "Project ID"}, {{"Count", each _, type table [Project ID=nullable number, Steep=nullable text, Attribute=text, Value=date, Index=number]}}),
        #"Duplicated Column" = Table.DuplicateColumn(#"Grouped Rows", "Count", "Count - Copy"),
        #"Aggregated Count" = Table.AggregateTableColumn(#"Duplicated Column", "Count", {{"Index", List.Min, "Min of Count.Index"}}),
        #"Expanded Count - Copy" = Table.ExpandTableColumn(#"Aggregated Count", "Count - Copy", {"Attribute", "Index", "Value"}, {"Count - Copy.Attribute", "Count - Copy.Index", "Count - Copy.Value"}),
        #"Added Custom" = Table.AddColumn(#"Expanded Count - Copy", "Custom", each [#"Count - Copy.Index"]-[Min of Count.Index]+1),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Min of Count.Index", "Count - Copy.Index"}),
        #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Steep]), "Steep", "Count - Copy.Value"),
        #"Removed Columns2" = Table.RemoveColumns(#"Pivoted Column",{"Count - Copy.Attribute", "Custom"})
    in
        #"Removed Columns2"

     

     

     

    Also added the PBIX file