Forum Discussion

Adham's avatar
Adham
Helper III
5 years ago
Solved

Power Query - Get data from another table if condition is met

Hello All,   I have been working on this all day with little luck, would really appreciate some support on this. I have two tables:   Table 1:   ID Status Value 1 Closed   33 2 Op...
  • AlB's avatar
    AlB
    5 years ago

    Adham 

    Just add the "try... otherwise" construct to catch the error and return null instead:

    = Table.AddColumn(#"Changed Type", "Custom", each if List.Contains({"Closed", "Long Term"}, [Status]) then [Value] else try Table.Sort(Table.SelectRows(Table2, (inner)=> inner[ID]=[ID]), {{"Date", Order.Ascending}})[Value]{0} otherwise null)

    Please mark the question solved when done and consider giving kudos if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers