Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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
Anonymous
Not applicable

Thank you so much. This works perfectly. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.