web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : IOZpWq2nl5dKrS1pWIe5jz
Power Automate - Building Flows
Answered

Get Items Filter Query - Multiple Conditions with If Statement

Like (0) ShareShare
ReportReport
Posted on 24 Dec 2022 20:10:09 by 1,042

Happy Holidays.

I'm attempting a Get items filter query such as:

  • A Field eq '{whatever was selected in automatic trigger input}' and (if another input field eq 'Yes', make a field Tune0/Textlisttxt eq 'Yes' otherwise/else, make (Tune0/Textlisttxt  'Yes' or make Tune0/Textlisttxt  'No')) i.e.: it s
  • The following works fine since there is no 'if' statement:
  • (Band eq '@{triggerBody()['text']}') and (Tune0/SetListtxt eq 'Yes' or Tune0/SetListtxt eq 'No')

 

 

  • BUT!!! That second part is not taking into consideration the second input trigger requirements yet. (See attachment of flow)
  • The second input parameter is triggerBody(['text_11']). Then, I've set a variable to return:
    • 'Yes' if Set list only is choosen,
    • 'No' if All music is chosen
    • Here's the variable: 
    • if(equals(triggerBody()['text_1'],'Setlist only'),'Yes','No')​

 

 

  • So, in the Filter Query, I've tried to implement the if statement to handle the logic but iot keeps failing and after many different configurations, can't find what is wqrong with my syntax. Here is what I've tried that makes most sense (to me 🙂)
  • (Band eq '@{triggerBody()['text']}') and (Tune0/SetListtxt eq '@{if(equals(variables('Music'),'Yes'),'Yes',Tune0/SetListtxt eq 'Yes' or Tune0/SetListtxt eq 'No')}')

Any assistance would be greatly appreciated.

NOTE: I tried at add the code as javascript but posting kept returning an error about bad HTML (?????). I think I've had enough errors for one day.

 

Thanks

I have the same question (0)
  • CW Profile Picture
    1,042 on 25 Dec 2022 at 15:14:38
    Re: Get Items Filter Query - Multiple Conditions with If Statement

    😄That worked nicely, thanks Grant. Great idea with the ne null!! It's hard when you're so subjective. Looking from the outside now it makes sense but yes, my syntax was a bit 'off'. I made the expression too complicated. 😬

     

    Cheers, Happy Holidays🎄

  • CW Profile Picture
    1,042 on 25 Dec 2022 at 02:44:16
    Re: Get Items Filter Query - Multiple Conditions with If Statement

    Will try that on Christmas day Grant thanks. That looks so similar to what I had, I'm going to have to pull it apart to see where I went wrong.

    I'll respond to you tomorrow. AS USUAL, thanks for the help. You have no idea how helpful you have been!!!!!.

     

    Carl

  • Verified answer
    grantjenkins Profile Picture
    11,059 Moderator on 25 Dec 2022 at 02:31:15
    Re: Get Items Filter Query - Multiple Conditions with If Statement

    Can you try the following. If Music is set to No it will return items that are not equal to null - which means it should return both Yes and No (all items).

     

    (Band eq '@{triggerBody()['text']}') and @{if(equals(variables('Music'), 'Yes'), '(Tune0/SetListtxt eq ''Yes'')', '(Tune0/SetListtxt ne null)')}

     

  • CW Profile Picture
    1,042 on 25 Dec 2022 at 01:00:06
    Re: Get Items Filter Query - Multiple Conditions with If Statement

    Hi Grant. 

     

    Almost. The variable only returns 'Yes' and 'No'. It'd need to be either 'Yes' or 'Yes' and 'No' as well as the 'and' Band. 

    That's why mine seems needlessly complicated. 

     

    So (Band eq Input) and (setlist eq yes if the Expression is yes otherwise setlist eq yes and/or no)

  • grantjenkins Profile Picture
    11,059 Moderator on 25 Dec 2022 at 00:02:36
    Re: Get Items Filter Query - Multiple Conditions with If Statement

    It looks like you're just trying to do the following:

     

    Band eq '@{triggerBody()['text']}' and Tune0/SetListtxt eq '@{variables('Music')}' 

     

    grantjenkins_0-1671926470127.png

     

    If that's not what you're after, then let me know.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 626 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 374 Moderator

#3
Expiscornovus Profile Picture

Expiscornovus 284 Most Valuable Professional

Last 30 days Overall leaderboard