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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Filter Array

(0) ShareShare
ReportReport
Posted on by 10

Hi! I am having trouble with my filter array. Can someone please help me figure out what I'm doing wrong?

 

and(

        not(equals(item()?['value'], '')),

        not(equals(item()?['value'], 'Other')),

        not(equals(item()?['value'], 'No')),

or(

equals(item()?['tabLabel'], 'tabLabel1'),

equals(item()?['tabLabel'], 'tabLabel2'),

equals(item()?['tabLabel'], 'tabLabel3'),

equals(item()?['tabLabel'], 'tabLabel4'),

equals(item()?['tabLabel'], 'tabLabel5'),

equals(item()?['tabLabel'], 'tabLabel6'),

equals(item()?['tabLabel'], 'tabLabel7'),

equals(item()?['tabLabel'], 'tabLabel8'),

equals(item()?['tabLabel'], 'tabLabel9'),

equals(item()?['tabLabel'], 'tabLabel10'),

equals(item()?['tabLabel'], 'tabLabel11'),

equals(item()?['tabLabel'], 'tabLabel12'),

equals(item()?['tabLabel'], 'tabLabel13'),

equals(item()?['tabLabel'], 'tabLabel14'),

equals(item()?['tabLabel'], 'tabLabel15'),

equals(item()?['tabLabel'], 'tabLabel16')

)

)

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @chelsea4 

    I use your code , i works good in my side , you need to check if you add '@' in the first character.

    @and(
     not(equals(item()?['value'], '')),
    
     not(equals(item()?['value'], 'Other')),
    
     not(equals(item()?['value'], 'No')),
    or(
    
    equals(item()?['tabLabel'], 'tabLabel1'),
    
    equals(item()?['tabLabel'], 'tabLabel2'),
    
    equals(item()?['tabLabel'], 'tabLabel3'),
    
    equals(item()?['tabLabel'], 'tabLabel4'),
    
    equals(item()?['tabLabel'], 'tabLabel5'),
    
    equals(item()?['tabLabel'], 'tabLabel6'),
    
    equals(item()?['tabLabel'], 'tabLabel7'),
    
    equals(item()?['tabLabel'], 'tabLabel8'),
    
    equals(item()?['tabLabel'], 'tabLabel9'),
    
    equals(item()?['tabLabel'], 'tabLabel10'),
    
    equals(item()?['tabLabel'], 'tabLabel11'),
    
    equals(item()?['tabLabel'], 'tabLabel12'),
    
    equals(item()?['tabLabel'], 'tabLabel13'),
    
    equals(item()?['tabLabel'], 'tabLabel14'),
    
    equals(item()?['tabLabel'], 'tabLabel15'),
    
    equals(item()?['tabLabel'], 'tabLabel16')
    
    )
    )

    vyueyunmsft_0-1704766304028.png

     

    The result is as follows:

    vyueyunmsft_1-1704766322347.png

     

     

    If this reply can help you , you can click mark this reply as solution, thanks in advance!


    Best Regards,

    Yueyun Zhang

  • JericaB Profile Picture
    on at

    Hi Yueyun,

     

    (editing cause I noticed it cut off). 

     

    To expand on the question, this is the issue we are running into. 

     

    With our current filter array, we will get one of three output arrays to work with; 

    1. input does NOT contain tabLabel “A Choice” or “B choice”. Thus, any output that does NOT have a tabLabel value of “A Options or B options” needs to be the final output.  So there will always be either: A Choice, A Options, B Options or B Choice, A Options, B Options. If A Choice is present, I need A Option to be the only output. If B Choice is present, I need B option to be the only output. 

      2. The item output is none of the above. 

     

    1. This is the input: 

    [

        {

            "tabLabel": "A Options",

            "value": "A"

            "documentId": "1",

            "recipientId": "8",

            "tabId": "9",

            "tabType": "listTabs",

            "prefill": false

        },

        {

            "tabLabel": "B choice",

            "value": "Yes",

            "documentId": "1",

            "recipientId": "EEE",

            "tabId": "UUU",

            "tabType": "listTabs",

            "prefill": false

        },

        {

            "tabLabel": "B Options",

            "value": "123",

            "documentId": "1",

            "recipientId": "YYY",

            "tabId": "XXX",

            "tabType": "listTabs",

            "prefill": false

        }

    ]

     

    1. This is the input:

     

     [

        {

            "tabLabel": "B Options",

            "value": "B"

            "documentId": "1",

            "recipientId": "9",

            "tabId": "9",

            "tabType": "listTabs",

            "prefill": false

        },

        {

            "tabLabel": "A choice",

            "value": "Yes",

            "documentId": "1",

            "recipientId": "EE",

            "tabId": "UU",

            "tabType": "listTabs",

            "prefill": false

        },

        {

            "tabLabel": "A Options",

            "value": "3",

            "documentId": "1",

            "recipientId": "Y",

            "tabId": "X",

            "tabType": "listTabs",

            "prefill": false

        }

    ]

     

    I need help writing an expression that says the following: 

    If A choice is present in the array, then A options needs to be the only item output. If B choice is present in the array, then B options needs to be the only item output. 
    If neither A choice nor B choice is present, then neither A options nor B options should be output in the result. 

    A couple of notes: 

    -I am working with a prior filter array output.
    -A options and B options will always appear, but should only be the final output IF A choice or B choice is present with it. 

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @JericaB @chelsea4 

    Thanks for your quick response! This is my test flow:

    vyueyunmsft_0-1704857058282.png

    My Compose action is used to create the test array to test.

    We can first use the Select action to get the all the [tabLabel]:

    vyueyunmsft_1-1704857130998.png

    Then we can use the Filter array action:

    vyueyunmsft_2-1704857163209.png

     

    @if(equals( length( intersection(createArray('A choice','B choice'),body('Select'))) , 0),
    and(not(equals(item()?['tabLabel'], 'A Options')) , not(equals(item()?['tabLabel'], 'B Options'))),
    contains(replace(join( intersection(createArray('A choice','B choice'),body('Select')), ';'), 'choice', 'Options'), item()?['tabLabel']) )

     

    As this test array has the "A choice", so the test result is like this in Filter array action:

    vyueyunmsft_3-1704857279516.png

     

     

    If this reply can help you , you can click mark this reply as solution, thanks in advance!


    Best Regards,

    Yueyun Zhang

     

  • Chriddle Profile Picture
    8,638 Super User 2026 Season 1 on at

    With xpath you can check if a value exists in an array and get the corresponding elements as XML nodes.

    In a final Select, you can convert these XML nodes back to JSON.

     

    Chriddle_0-1704876756737.png

     

    Compose 2

     

    if(
    	greater(
    		length(
    			xpath(
    				xml(json(concat('{"Root":{"Item":', outputs('Compose'),'}}'))),
    				'//Item[tabLabel="A choice"]'
    			)
    		),
    		0
    	),
    	xpath(
    		xml(json(concat('{"Root":{"Item":', outputs('Compose'),'}}'))),
    		'//Item[tabLabel="A Options"]'
    	),
    	if(
    		greater(
    			length(
    				xpath(
    					xml(json(concat('{"Root":{"Item":', outputs('Compose'),'}}'))),
    					'//Item[tabLabel="B choice"]'
    				)
    			),
    			0
    		),
    		xpath(
    			xml(json(concat('{"Root":{"Item":', outputs('Compose'),'}}'))),
    			'//Item[tabLabel="B Options"]'
    		),
    		xpath(
    			xml(json(concat('{"Root":{"Item":', outputs('Compose'),'}}'))),
    			'//Item[tabLabel != "A Options" and tabLabel != "B Options"]'
    		)
    	)
    )

     

     

    Select

    From:

     

    outputs('Compose_2')

     

    Map:

     

    json(item())['Item']

     

     

    Result

     

    [
     {
     "tabLabel": "A Options",
     "value": "3",
     "documentId": "1",
     "recipientId": "Y",
     "tabId": "X",
     "tabType": "listTabs",
     "prefill": "false"
     }
    ]

     

     

  • Chriddle Profile Picture
    8,638 Super User 2026 Season 1 on at

    These JSONs are invalid (comma missing)

  • JericaB Profile Picture
    on at

    Hi Yueyun, 

    Using the filter you listed above returned the 'Choice' tab, instead of the 'Options' tab. What would I change in the equation for this? 

    EDIT/UPDATE: Nope, that was my bad. I substituted the wrong real tabLabels when I copied the formula over. 

     

    Thank you - I'm going to do a full test run now. 

  • JericaB Profile Picture
    on at

    Hi Chriddle,

     

    The first time I tried this it didn't work but now it is lol. Love it. Thank you!

  • JericaB Profile Picture
    on at

    Hi Chriddle -

     

    Hope you can help me out. Thought it was working; I can't get it to output anything except the formula.

    JericaB_1-1705960072026.png

     

    If I put this as a function, the 'compose' returns nothing. 

    Not sure what I'm doing wrong here? Also how I used this earlier and received an item output (though the wrong one) and now it doesn't show any output, lol. 

  • JericaB Profile Picture
    on at

    I still receive the item that is listed as the 'choice' tab. 

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @JericaB 

    Dose i misunderstand your needs?

    This is my code:

    @if(equals( length( intersection(createArray('A choice','B choice'),body('Select'))) , 0),
    and(not(equals(item()?['tabLabel'], 'A Options')) , not(equals(item()?['tabLabel'], 'B Options'))),
    contains(replace(join( intersection(createArray('A choice','B choice'),body('Select')), ';'), 'choice', 'Options'), item()?['tabLabel']) )

     

    If the json dose not have the [A choice] or [B choice] , it will not return [A Options] and [B Options].

    If the json  have the [A choice] ,it will return  [A Options] .

    If the json  have the [B choice] ,it will return  [B Options] .

     

    If I misunderstand what you mean, you can describe your needs and your expected outcomes in detail so that we can better help you. Can you give a example and what you need in the end.

     

    Best Regards,

    Yueyun Zhang

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 227

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard