How to express @contains with two conditions (originally had one condition)?

King Java 750 Reputation points
2024-12-16T19:44:35.7033333+00:00

This question is directly related to this thread, but since this is very specific question, I created a new thread there.

I am trying to come up with an expression where string(item().name) contains Both:

  1. pipeline().parameters.locations &
  2. formatDateTime(adddays(utcNow(),0),'yyyyMMdd')

    @contains( string(item().name), pipeline().parameters.locations & xxxxxx? )

This is original one:

@contains(string(item().name),pipeline().parameters.locations)

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,375 questions
0 comments No comments
{count} votes

Accepted answer
  1. hossein jalilian 10,340 Reputation points
    2024-12-16T21:36:41.24+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    You need to use the and function along with two separate contains functions. Here's how you can modify your expression:

    @and(
        contains(string(item().name), pipeline().parameters.locations),
        contains(string(item().name), formatDateTime(adddays(utcNow(),0),'yyyyMMdd'))
    )
    
    

    This expression checks if the item().name contains both the pipeline().parameters.locations and the formatted date string. The and function ensures that both conditions are true for the overall expression to evaluate to true

    If you need to use this in an If Condition activity, you can wrap it in an @if function:

    @if(
        and(
            contains(string(item().name), pipeline().parameters.locations),
            contains(string(item().name), formatDateTime(adddays(utcNow(),0),'yyyyMMdd'))
        ),
        'true_result',
        'false_result'
    )
    
    

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.