Forum Discussion

jburbano's avatar
jburbano
Frequent Visitor
1 year ago
Solved

New Column returns a list, when I try to access list using {0} it refreshed forever

This is my code:     let Source = AzureStorage.Tables("mytable"), Environments1 = Source{[Name="Environments"]}[Data], #"Expanded Content" = Table.ExpandRecordColumn(Environments1, "C...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi jburbano ,

    Thanks for watkinnc's reply!

    And jburbano , The issue you're experiencing with the column not finishing refreshing when you use `{0}` in your Power Query code is likely due to the fact that when `{0}` is used, it attempts to access the first element of a list. If the list is empty (i.e., no rows match the filter criteria in `Table.SelectRows`), this will lead to an error or cause the operation to hang as it cannot return a value.
    Please try to adjust your code like this and see whether it will work:

    #"Added Predecessor" = Table.AddColumn(
        #"Added Platform", 
        "Predecessor", 
        each (
            let #"Predecessor Parent" = _ in
            let 
                #"Predecessor Source" = Table.SelectRows(
                    #"Added Platform",
                    each (
                        [PartitionKey] = #"Predecessor Parent"[PartitionKey] and 
                        [releaseId] = #"Predecessor Parent"[releaseId] and 
                        [environment.rank] = #"Predecessor Parent"[environment.rank]-1
                    )
                )
            in
            if Table.IsEmpty(#"Predecessor Source") then 
                "N/A" 
            else 
                List.First(#"Predecessor Source"[environment.status], "N/A")
        ),
        type text
    )

    If this method doesn't work, then as @SU said, it's difficult for us to help you find a solution with only the M code and no other information. Please provide as much information as possible. Thank you!

    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.