dynamic If expression along with concat in Set Variable Activity

Swapneel Hosur 106 Reputation points
2022-11-24T09:45:07.687+00:00

Hi Team,

I am trying to pass dynamic values to if expression inside an expression builder for Set Variable activity. To provide you with a context :

  1. I am filtering records in Azure Data Flow and generating a file in azure blob storage
  2. The file may have rows written or may not apart from the header
  3. I would like to send email notification to stakeholders mentioning the rows written to the file, and if there are no rows then I don't want to include that line in the email message.

Below is my code:

@markus.bohland@hotmail.de ('<hr/><h2 style=''color:Green''>Pipeline Run Finished</h2><hr/>Data Factory Name: <b>', pipeline().DataFactory,
'</b><br/>Pipeline Name: <b>',pipeline().Pipeline,
'</b><br/>Pipeline Run Id: <b>',pipeline().RunId,
'</b><br/>Trigger Time: <b>',formatDateTime(convertTimeZone(pipeline().TriggerTime,'UTC','Eastern Standard Time'), 'yyyy-MM-ddTHH:mm:ssZ'),
if(greaterOrEquals(activity('Data flow1').output.runStatus.metrics.WriteReviewRecords.rowsWritten,2), '</b><br/><font color="red" Review Note: There are ',activity('Data flow1').output.runStatus.metrics.WriteReviewRecords.rowsWritten,' record(s) where Claim Date exceeds Filing Date by 30 days </font>',''),
'</b><br/><hr/><p style =''color:gray;''>This email was generated automatically. Please do not respond to it. </p>')

I am getting error as "if expression cannot have more than 3 inputs".

Any ideas?

Thank you
Swapneel

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

Accepted answer
  1. AnnuKumari-MSFT 34,556 Reputation points Microsoft Employee Moderator
    2022-11-25T08:01:54.787+00:00

    Hi @Swapneel Hosur ,

    Welcome to Microsoft Q&A platform and thanks for posting your query here.

    As I understand your issue, you are receiving a syntax error while using if condition in set variable activity in ADF pipeline. Please let me know if that is not the case.

    The issue here is that since you are using ',' for concatenating the strings , ADF is treating concatenated string as one of the parameters in if condition as parameters are separated by comma in if condition.

    Instead of using concat , try string interpolation like below:
    @if(greaterOrEquals(activity('Data flow1').output.runStatus.metrics.WriteReviewRecords.rowsWritten,2), '</b><br/><font color="red" Review Note: There are @{activity('Data flow1').output.runStatus.metrics.WriteReviewRecords.rowsWritten} record(s) where Claim Date exceeds Filing Date by 30 days </font>','')

    To know more about String interpolation , kindly check: How to do string interpolation in Azure Data Factory

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.
      Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    1 person found this answer helpful.

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.