Forum Discussion

nicholas888's avatar
nicholas888
Copper Contributor
Jun 24, 2021

Using an array with where statement

I am trying to pass an array to the where clause, please see example below:

 

let terms = pack_array('12345', 'ABC123');
ADFPipelineRun
| where ResourceId has_any (terms)

 

I am aware I can use where statements with 'and'  'or' operators with multiple values, but we could be looking at 100s different values.

Can someone please advise on the best approach?

2 Replies

  • nicholas888 - assuming you're looking to match full strings, you'll want to use the "in" operator to achieve this. To reuse your example, your query becomes:

    let terms = pack_array('12345', 'ABC123');
    ADFPipelineRun
    | where ResourceId in (terms)

     

    "has_any", as you have it, would be more the equivalent of Col contains 'term1' OR Col contains 'term2' OR [...]. "In" replaces the contains with ==s.

    • nicholas888's avatar
      nicholas888
      Copper Contributor

      Evgeny Ternovsky - we tried to match the resource name and not the whole string.

      example:

      we need a match 39515 only.  So IN will not work.

      Please advise.

Resources