Forum Discussion

vijaykaali811's avatar
1 year ago
Solved

extract particular value from list record column in power query

i have column additionaldata as list type , that  list contains key value records like "OS" :rhel , "version","rhel8 like  that . without expanding all list and record as it is creating duplicate re...
  • danextian's avatar
    1 year ago

    Hi vijaykaali811 

     

    To get a specific item from a list without expanding it, you can use access the position of an item - which always begins at zero. Assuming List of Records is the name of the list column, you can create a custom column with this formula

    [List of Records]{0} // This retrieves the first record from the "List of Records" column
    [List of Records]{0}[OS] // This accesses the value associated with the "OS" key in the first record of the "List of Records" column

    Sample query:

    let
        Source =
            Table.FromRecords({
                [ID = 1, List of Records = { [OS = "rhel"], [version = "rhel8"], [Arch = "x86_64"] }],
                [ID = 2,  List of Records = { [OS = "ubuntu"], [version = "20.04"], [Arch = "arm64"] }],
                [ID = 3,  List of Records = { [OS = "centos"], [version = "7"], [Arch = "x86_64"] }]
            }),
        #"Added Custom" = Table.AddColumn(Source, "OS", each [List of Records]{0}[OS]),
        OS = #"Added Custom"{1}[OS]
    in
        OS