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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
steve1024
Frequent Visitor

Expand list and column

Hi,

 

I have a table with two columns (key = list of with two key values in each item & values = a numeric measure)

 

steve1024_0-1668594783966.png

 

each item of the list looks like this:

steve1024_1-1668594876717.png

 

I would like to transform each into a single row looking like this example:

KIFI   1996M11       101.4

 

If I just expand the list it does not create the desired result but duplicate records, one for each item in the list:

steve1024_2-1668595271943.png

 

How do I do this properly and get the two key values in seperte columns alongside the numeric value?

 

thanks for all help

 

1 ACCEPTED SOLUTION
AntrikshSharma
Super User
Super User

@steve1024 Use Record.FromList (), paste the below code in Advanced Editor:

let
    Source = 
        Table.FromRows (
            { { { "KIFI", "1996M11" }, 91 } } & { { { "KIKI", "12346" }, 125 } },
            type table [ Key = list, Values = number ]
        ),
    AddedCustom = 
        Table.AddColumn (
            Source,
            "Custom",
            each Record.FromList ( [Key], { "Key 1", "Key 2" } )
        ),
    ExpandedCustom = 
        Table.ExpandRecordColumn (
            AddedCustom,
            "Custom",
            { "Key 1", "Key 2" },
            { "Key 1", "Key 2" }
        ),
    RemovedColumns = Table.RemoveColumns ( ExpandedCustom, { "Key" } )
in
    RemovedColumns

 AntrikshSharma_0-1668597356697.png

 

View solution in original post

5 REPLIES 5
AntrikshSharma
Super User
Super User

@steve1024 Use Record.FromList (), paste the below code in Advanced Editor:

let
    Source = 
        Table.FromRows (
            { { { "KIFI", "1996M11" }, 91 } } & { { { "KIKI", "12346" }, 125 } },
            type table [ Key = list, Values = number ]
        ),
    AddedCustom = 
        Table.AddColumn (
            Source,
            "Custom",
            each Record.FromList ( [Key], { "Key 1", "Key 2" } )
        ),
    ExpandedCustom = 
        Table.ExpandRecordColumn (
            AddedCustom,
            "Custom",
            { "Key 1", "Key 2" },
            { "Key 1", "Key 2" }
        ),
    RemovedColumns = Table.RemoveColumns ( ExpandedCustom, { "Key" } )
in
    RemovedColumns

 AntrikshSharma_0-1668597356697.png

 

Image.jpeg

Hello, thanks for your response to the question. I have a similar issue but mine is a little complicated. I am using a JSON for my analysis containing lots of arrays and embedded documents. I have been able to expand all the arrays and embedded documents but I want them to be in a single row.

I look forward to hearing from you.

 

Thanks and regards.

 

 

Hi Antriksh, you are probely right. for some reason I am getting errors on the AddCustom, but maybe this is more relted to some errors in previous steps

 

here is the full code I am trying out:

 

let
  content = "{#(lf)  ""query"": [],#(lf)  ""response"": {#(lf)    ""format"": ""json""#(lf)  }#(lf)}",
  Source = Json.Document(Web.Contents("http://.../Indikatorm.px", [Content=Text.ToBinary(content)])),
  Navigation = Source[data],
  Table_1 = Table.FromList(Navigation, Splitter.SplitByNothing(), nullnull, ExtraValues.Error),
  Table_2 = Table.ExpandRecordColumn(Table_1, "Column1", {"key""values"}, {"key""values"}),
  Table_3 = Table.ExpandListColumn(Table_2, "values")
  ,
    AddedCustom = 
        Table.AddColumn (
            Table_3,
            "Custom",
            each Record.FromList ( [Key], { "Key 1""Key 2" } )
        ),
    ExpandedCustom = 
        Table.ExpandRecordColumn (
            AddedCustom,
            "Custom",
            { "Key 1""Key 2" },
            { "Key 1""Key 2" }
        ),
    RemovedColumns = Table.RemoveColumns ( ExpandedCustom, { "Key" } )
in
    RemovedColumns

@steve1024 Yes, your Content step is messed up because of those line feeds #(lf), you probably removed something from the step inadvertently that broke it, I do that all the time when moving too quickly.

steve1024
Frequent Visitor

just for clarity: the desired result should look like this (three seperat columns, 2 key columnd and one value column)

 

KEY 1   KEY 2    Value
KIFI2022M10    123.3

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.