Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

IF statement comparing two fields

(0) ShareShare
ReportReport
Posted on by 47

Hi all,

I'm inputting an if statement into my email but want to compare the value of one field to another in the system, whilst I get no errors when setting the logic up, the output is blank in tests where it should be showing the information. The below is an example of the code I'm using. Is there a way to make this work, or is it impossible to compare the values in two fields and only show dynamic content if they match?

{{#if ( eq contact.A contact.B)}}
    THIS IS A TEST
{{/if}}

Thanks, Charlie

  • slx Profile Picture
    386 on at
    RE: IF statement comparing two fields

    thank you, do you know if you can search and compare values in an array/iteration [tag:each] ?

    example [tag:each] returning 3 values, compare array[0] with array[1]

  • Leco Lv Profile Picture
    on at
    RE: IF statement comparing two fields

    Hi partner,

    Josh is right. it is possible. hope this link helps you.

    https://docs.microsoft.com/en-us/dynamics365/marketing/dynamic-email-content#conditional-statements-and-comparisons

  • Suggested answer
    Josh - Microchannel Profile Picture
    45 on at
    RE: IF statement comparing two fields

    Hey Charlie,

    This is perfectly valid logic. I also created a test scenario setting both the contacts first name and last name as the same value and using the following statement to display text if they match.

    {{#if (eq contact.firstname contact.lastname)}}
    You have a match!
    {{/if}}

    "You have a match!" only displays when the two fields have an exact match. This is also case sensitive.

    Please check the fields are of the same data type and you are using the field logical name.

    Looking forward to hearing how you go.

    All the best,
    Josh

  • Josh - Microchannel Profile Picture
    45 on at
    RE: IF statement comparing two fields

    Hey Charlie,
    This is perfectly valid logic. I also created a test scenario setting both the contacts first name and last name as the same value and using the following statement to display text if they match.

    {{#if (eq contact.firstname contact.lastname)}}
    You have a match!
    {{/if}}

    "You have a match!" only displays when the two fields have an exact match. This is also case sensitive.

    Please check the fields are of the same data type and you are using the field logical name.

    Looking forward to hearing how you go.

    All the best,
    Josh

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Holly Huffman Profile Picture

Holly Huffman 103

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 96 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 51 Most Valuable Professional

Product updates

Dynamics 365 release plans