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

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

Reply
Anonymous
Not applicable

Table.ExpandListColumn - list splitting and avoiding rows duplicating

Hi all,

I am parsing a JSON with nested records and lists. Now I'm using the Advanced Editor and I'm trying a way to split my list and take just the field of the first occurrency (it's dating sorted and it's fine for me taking the first one).

The problem is that i'm using the Table.ExpandListColumn function that splits the list into a row for each item and values in the other columns are duplicated in each new row created.

Is there any other way to do it?

 

thanks

Antonio

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

try adapting this code, it takes first record from the list of records:

let
    Source = Json.Document(File.Contents("C:\tests\test.json")),
    #"Converted to Table" = Record.ToTable(Source),
    #"Transposed Table" = Table.Transpose(#"Converted to Table"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"data", type any}, {"message", type any}, {"status", type any}}),
    #"Expanded data" = Table.ExpandRecordColumn(#"Changed Type", "data", {"ratio", "annualized", "payments"}, {"ratio", "annualized", "payments"}),
    #"Expanded payments" = Table.ExpandRecordColumn(#"Expanded data", "payments", {"rows"}, {"rows"}),
    transform = Table.TransformColumns(#"Expanded payments", {{"rows", each _{0}, type text}})
in
    transform

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

4 REPLIES 4
Stachu
Community Champion
Community Champion

Can you add sample tables (in format that can be copied to PowerBI) from your model with anonymised data? Like this (just copy and paste into the post window).

Column1 Column2
A 1
B 2.5

also the JSON example would be very helpful



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Thanks for answering me

 

here a sample json response I get from a rest service that I call with customer name

{
"data": {
"ratio": "5.89%",
"annualized": "0.88",
"payments": {
"rows": [
{
"effectiveDate": "02/06/2020",
"type": "cash",
"amount": "$0.22",
"declarationDate": "01/28/2020",
"recordDate": "02/07/2020",
"paymentDate": "02/13/2020"
},
{
"effectiveDate": "11/01/2019",
"type": "check",
"amount": "$0.22",
"declarationDate": "10/23/2019",
"recordDate": "11/04/2019",
"paymentDate": "11/14/2019"
},
{
"effectiveDate": "08/02/2019",
"type": "check",
"amount": "$0.22",
"declarationDate": "07/24/2019",
"recordDate": "08/05/2019",
"paymentDate": "08/15/2019"
}
]
}
},
"message": null,
"status": {
"rCode": 200,
"bCodeMessage": null,
"developerMessage": null
}
}

 

for each customer i have different answer and for each answer I woul like to insert just one row as following

and here the table that I would like to realize

RatioannualizedeffectiveDatedeclarationDatetypegap
$.data.ratio $.data.annualized data.payments.rows[0].effectiveDate data.payments.rows[0].declarationDate data.payments.rows[0].type effectiveDate-declarationDate

 

 

Since Expanding list mean duplicating at least three columns means having a very heavy table

 

thanks for your help

 

Stachu
Community Champion
Community Champion

try adapting this code, it takes first record from the list of records:

let
    Source = Json.Document(File.Contents("C:\tests\test.json")),
    #"Converted to Table" = Record.ToTable(Source),
    #"Transposed Table" = Table.Transpose(#"Converted to Table"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"data", type any}, {"message", type any}, {"status", type any}}),
    #"Expanded data" = Table.ExpandRecordColumn(#"Changed Type", "data", {"ratio", "annualized", "payments"}, {"ratio", "annualized", "payments"}),
    #"Expanded payments" = Table.ExpandRecordColumn(#"Expanded data", "payments", {"rows"}, {"rows"}),
    transform = Table.TransformColumns(#"Expanded payments", {{"rows", each _{0}, type text}})
in
    transform

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

it worked without the "type text" at the end

 

thanks a lot

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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 Kudoed Authors