Forum Discussion

LotteLaugesen's avatar
4 years ago
Solved

How to get a default value (zero) when Table.SelectRows doesn't return a value

Hi

 

Is there a way to return zero when [order number] isn't present in FT_table?
Here is my query:
(let currentOrder = [order number] in Table.SelectRows(FT_Table, each [order number] = currentOrder)){0}[SupplierID]

 

BR

Lotte

  • AlexisOlson's avatar
    AlexisOlson
    4 years ago

    It's generally better to handle the errors rather than replace them.

     

    Try this:

    let
        currentOrder = [order number],
        filteredTable = Table.SelectRows(FT_Table, each [order number] = currentOrder))
    in
        try filteredTable{0}[SupplierID] otherwise 0

3 Replies

    • AlexisOlson's avatar
      AlexisOlson
      Super User

      It's generally better to handle the errors rather than replace them.

       

      Try this:

      let
          currentOrder = [order number],
          filteredTable = Table.SelectRows(FT_Table, each [order number] = currentOrder))
      in
          try filteredTable{0}[SupplierID] otherwise 0