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

get Json array and generate rows and columns

Got this json array in a column but need to separate its positions by multiple columns and rows

[{'from': 200000, 'until': 700000, 'value': 40000}, {'from': 700001, 'until': 1200000, 'value': 60000}, {'from': 1200001, 'until': 11999999, 'value': 80000}, {'from': 12000000, 'until': -1, 'value': 120000}]

 

each from, until, value need to be in a separated row. the next shot is the tabled showed in Power Query 

JuanSC566_0-1657210987624.png

 

5 REPLIES 5
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkwpV9JRiq6OKTUwMDJPK8rPhbCsFIwMQEBHAcIvzSvJzIFJmaNIlSXmlKbCpExAMrU6ClgMBOsyxGqgoRFuE81wmwjRhsNIQ0swwGqmBSEzcXhc1xCrcRA9tbHAkDRVio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [_id = _t, studyvalue = _t, paymentpercentage = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"'","""",Replacer.ReplaceText,{"studyvalue"}),
    #"Added Custom" = Table.ReplaceValue(#"Replaced Value",each [studyvalue],each Json.Document([studyvalue]),Replacer.ReplaceValue,{"studyvalue"}),
    #"Expanded studyvalue" = Table.ExpandListColumn(#"Added Custom", "studyvalue"),
    #"Expanded studyvalue1" = Table.ExpandRecordColumn(#"Expanded studyvalue", "studyvalue", {"from", "until", "value"}, {"from", "until", "value"})
in
    #"Expanded studyvalue1"

 

This looks good.

 

One small simplification would be to use the GUI to click Transform > Text Column > Parse > JSON.

AlexisOlson_0-1657488878573.png

 

This generates the code

 

#"Parsed JSON" = Table.TransformColumns(#"Replaced Value",{{"studyvalue", Json.Document}}),

 

instead of

 

#"Added Custom" = Table.ReplaceValue(#"Replaced Value",each [studyvalue],each Json.Document([studyvalue]),Replacer.ReplaceValue,{"studyvalue"}),

 

Anonymous
Not applicable

Greetings. Tried this one, but I got an error message about additional characters found at the end of the JSON entrance. 

Details: Value = ' Position = 2

 

here's another example of a field with the same form: 

 

[{'applicationid': '', 'state': 0, 'changedate': {'seconds': 1652714199, 'nanos': 530721737}, 'userrol': 'system', 'userid': 'system'}]

Greg_Deckler
Community Champion
Community Champion

@Anonymous So, dumb question, but is this coming from a JSON file? Because something like this works fine when importing via JSON connection. 

{
	"_id": "61f872",
	"studyvalue": [{"from": 200000, "until": 700000, "value": 40000}, {"from": 700001, "until": 1200000, "value": 60000}, {"from": 1200001, "until": 11999999, "value": 80000}, {"from": 12000000, "until": -1, "value": 120000}],
	"paymentpercentage": "7"
}

 

Otherwise I believe you will need to use Json.FromValue:

Json.FromValue - PowerQuery M | Microsoft Docs

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

I'm getting the data directly from a MongoDB Database collection, via Python script

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.

Top Solution Authors