cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Surafel
Helper II
Helper II

Changing the shape of my table to use it in Radar visualization

  In order to create a radar visualization, I need to do some pivoting and unpivoting of my data.  

 

My data looks like below:

 

Name       stats1       stats2   stats3  stats4  
Jack526.4578.4547857451
Henry125494652.721542047
Smith1487.2452414783087
Daniel4152.7147936411480
Olivia7884.94896520544308

 

I want to make it into the following shape:

 

 

Metrics   Jack     Henry     Smith     Daniel    Olivia       
stats1526.412541487.24152.77884.9
stats2578.494652.74524147948965
stats3547852154147836412054
stats474512047308714804308

 

  Is there anyone who can help me with this?  

1 ACCEPTED SOLUTION
KNP
Super User
Super User

Paste the below into the advanced editor of a blank query.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "XY5BC8IwDIX/ivQ8ypqlTXb3IB704HHsUGRgcdvBFcF/b5oKir28l5cvSYfBnOIy7eozjdlyzJv7q+HHd1+LYsdmMMd4vUvmIVgsSlwVib0ooXfKHab18ZLAgS/9HoMHS+LAaQAtkoKXJeVbAZHJghj0gFoTi3QtV24f1zTNpe8+m4ToCxHQ1flWwfOcnimWvzCjLQRyH7ze1NMoO804vgE=",
          BinaryEncoding.Base64
        ),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [
        #"(blank)" = _t,
        #"(blank).1" = _t,
        #"(blank).2" = _t,
        #"(blank).3" = _t,
        #"(blank).4" = _t
      ]
  ),
  #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars = true]),
  #"Changed Type" = Table.TransformColumnTypes(
    #"Promoted Headers",
    {
      {"stats1       ", type number},
      {"stats2   ", type number},
      {"stats3  ", Int64.Type},
      {"stats4  ", Int64.Type}
    }
  ),
  #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(
    #"Changed Type",
    {"Name       "},
    "Attribute",
    "Value"
  ),
  #"Pivoted Column" = Table.Pivot(
    #"Unpivoted Other Columns",
    List.Distinct(#"Unpivoted Other Columns"[#"Name       "]),
    "Name       ",
    "Value",
    List.Sum
  )
in
  #"Pivoted Column"

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

2 REPLIES 2
KNP
Super User
Super User

Paste the below into the advanced editor of a blank query.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "XY5BC8IwDIX/ivQ8ypqlTXb3IB704HHsUGRgcdvBFcF/b5oKir28l5cvSYfBnOIy7eozjdlyzJv7q+HHd1+LYsdmMMd4vUvmIVgsSlwVib0ooXfKHab18ZLAgS/9HoMHS+LAaQAtkoKXJeVbAZHJghj0gFoTi3QtV24f1zTNpe8+m4ToCxHQ1flWwfOcnimWvzCjLQRyH7ze1NMoO804vgE=",
          BinaryEncoding.Base64
        ),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [
        #"(blank)" = _t,
        #"(blank).1" = _t,
        #"(blank).2" = _t,
        #"(blank).3" = _t,
        #"(blank).4" = _t
      ]
  ),
  #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars = true]),
  #"Changed Type" = Table.TransformColumnTypes(
    #"Promoted Headers",
    {
      {"stats1       ", type number},
      {"stats2   ", type number},
      {"stats3  ", Int64.Type},
      {"stats4  ", Int64.Type}
    }
  ),
  #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(
    #"Changed Type",
    {"Name       "},
    "Attribute",
    "Value"
  ),
  #"Pivoted Column" = Table.Pivot(
    #"Unpivoted Other Columns",
    List.Distinct(#"Unpivoted Other Columns"[#"Name       "]),
    "Name       ",
    "Value",
    List.Sum
  )
in
  #"Pivoted Column"

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

Thank you so much. This works perfectly. 

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors