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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

API Data Transforming

I have an issue when transforming the data from an API and getting it into a useable format. I need to be calling a dynamic amount of columns from the API (Right now I have in the example below only 6 attributes pulling in, but the user can enter as many attributes as they want). Once they enter the attributes though, I have not been able to figure out how to format the data in a way that the steps in power query will be able to do it automatically for an ever-changing number of attributes.

Below is the table we have, an identifier, an attribute and its value. This is how the data is coming in.

1treetypeelm
1treenameelmhurst
1treecolorbrown
1locationSF
1originWI
1strength3
2treetypeelm
2treenameelmhurst
2treecolorbrown
2locationSF
2originWI
2strength3
3treetypeelm
3treenameelmhurst
3treecolorbrown
3locationSF
3strength3

What I need it to be is like the below, but I cannot figure out how to transform this for a number of attributes that are changing (as you see from the example above, tree 3 does not have an origin, so some data might also be incomplete).

 

 treetype treename treecolor location origin strength
1elmelmhurstbrownSFWI3
2oakoakygreenLASF2
3evergreengreenforestWI 5

 

Any help would be appreciated!

1 ACCEPTED SOLUTION
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

HI @Anonymous - you should be able to use the Pivot function.  The key part is "Don't Aggregate".

DarylLynchBzy_0-1661460492609.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc7BCoMwDMbxd+nZy5J3EHbewYN4UClaqI3EiOztF0U6xqK3j3+g/dW1e7jCCXsv79nr9HFyTfHNqZ3OPK68yM+tp0isu2PaUr5E6lsJlHS+ylyJwxD2Vj1zW/SRNMioE48ItgVuLHBpAdMChgUsC9oWvLHgpQVNC/7923wA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Index = _t, Attribute = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index", Int64.Type}, {"Attribute", type text}, {"Value", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

 

DarylLynchBzy_1-1661460565216.png

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This works-  I was also able to add more attribute / value pairs and this also works when you add more in power query without touching the steps. Exactly what I was looking for. Thank you so much!

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

HI @Anonymous - you should be able to use the Pivot function.  The key part is "Don't Aggregate".

DarylLynchBzy_0-1661460492609.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc7BCoMwDMbxd+nZy5J3EHbewYN4UClaqI3EiOztF0U6xqK3j3+g/dW1e7jCCXsv79nr9HFyTfHNqZ3OPK68yM+tp0isu2PaUr5E6lsJlHS+ylyJwxD2Vj1zW/SRNMioE48ItgVuLHBpAdMChgUsC9oWvLHgpQVNC/7923wA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Index = _t, Attribute = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index", Int64.Type}, {"Attribute", type text}, {"Value", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

 

DarylLynchBzy_1-1661460565216.png

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.