cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
darvinm
Frequent Visitor

Need Help With IF Expression

Good day! I'm a bit new to Power Automate and need help with an IF expression that keeps returning "The expression is invalid." I enjoy working with Excel and I am probably assuming it should work similarly to it and that's probably my problem. Here is what I would like to accomplish.

 

I am using the "Get User Profile (V2)" to extract an email and want to compare the returned email to a specific email address. If it is the same I want one response and if it is not the same I would like another. I would like to expand this to check multiple email addresses but I need to get it working with one first!

 

I tried this expression in both a "Compose" and "Initialize Variable" but get the same "Invalid" message on either.

 

if(outputs('Get_user_profile_(V2)')?['body/mail']='me@my-email.com','Match','No Match')

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

You were not far wrong, try this instead:

if
(
	equals(outputs('Get_user_profile_(V2)')?['body/mail'],'me@my-email.com'),
	'Match',
	'No Match'
)

View solution in original post

4 REPLIES 4
kdavis91
Continued Contributor
Continued Contributor

@darvinm,

 

Have you considered using a "condition" action block?

 

thanks,

Kyle

darvinm
Frequent Visitor

Thanks for replying! Yes I have thought of that but I plan to have at least 6 email addresses to check against so I would have to nest the conditions. I was hoping to avoid having to nest that many conditions in this flow for reasons I wont explain for fear of boring you! Using conditions will be my last resort if I can't figure out the expression.

Paulie78
Super User
Super User

You were not far wrong, try this instead:

if
(
	equals(outputs('Get_user_profile_(V2)')?['body/mail'],'me@my-email.com'),
	'Match',
	'No Match'
)
darvinm
Frequent Visitor

Thanks! That did it. I appreciate it. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Users online (2,979)