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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filtering for multiple...
Power Automate
Unanswered

Filtering for multiple conditions and a dynamic column name

(0) ShareShare
ReportReport
Posted on by 7

Hello - I'm creating a flow that's generating push notifications based on data in an Excel workbook, and trigger in a SharePoint list.  The Excel workbook contains users who will receive the notifications, based on either their Country, Region on Territory (depending on what's selected when creating the SharePoint item, and there could be a single or multiple values to filter in the corresponding column).

 

First NameemailCountryBranchTerritoryRegion
MichaelMichael@fakeemail.comUSUS114US114MNAMER
Daniel PDaniel@fakeemail.comUSUS107US107JNAMER
CharlesCharles@fakeemail.comUSUS114US114HNAMER
RomanRoman@fakeemail.comARAR101AR101ALATAM
JohnJohn@fakeemail.comUSUS114US114HNAMER
MatiasMatias@fakeemail.comARAR101AR101ALATAM
SergioSergio@fakeemail.comARAR101AR101ALATAM
AbelAbel@fakeemail.comARAR101AR101ALATAM

 

These are the 2 fields in SharePoint:

cm230002_0-1715901299957.png

The "Approver_Level" field would determine which of the 4 columns to filter in Excel, and the "UserListFilter" will have the filter values.

In the first example, we would filter by the "Branch" column for US114 or US117, and the push notification would go to:

First NameemailCountryBranchTerritoryRegion
MichaelMichael@fakeemail.comUSUS114US114MNAMER
Daniel PDaniel@fakeemail.comUSUS107US107JNAMER
CharlesCharles@fakeemail.comUSUS114US114HNAMER
JohnJohn@fakeemail.comUSUS114US114HNAMER

 

In the 2nd, we would filter the "Territory" column for US114M or US107J, and the push notification would go to:

 

First NameemailCountryBranchTerritoryRegion
MichaelMichael@fakeemail.comUSUS114US114MNAMER
Daniel PDaniel@fakeemail.comUSUS107US107JNAMER

 

And so on....there are ~10000 users in the Excel file, across dozens of countries, hundreds of branches, etc.

 

In an earlier version of the Flow as I was developing it, I have everything working except for dynamically selecting the column to filter.

cm230002_1-1715901622983.png

The Compose is splitting the "UserListFilter" field by ';', and the Initialize Variable turns it into the varUserFilter variable that's used in the  @ contains formula - @contains(variables('varUserFilter'),item()?['Territory'])

My first attempt was to initialize another variable to replace ['Territory'], but either that doesn't work or I can't get the syntax right with it.

**NOTE the change to the first variable name, this is correct

@contains(variables('varFilterValues'),item()?['varFilterColumn']) returns no values, even with data that matches:

 

cm230002_2-1715902483963.png

 

If it helps, I've added Select Query in the List Rows Present action to only select the email, employee ID and varFilterColumn columns from Excel, so now varFilterColumn will always be the 3rd column in the array - so that could be used in the @contains formula (Column = 3) instead of the variable.

 

Here's the full flow if it helps - sorry for the long post and please help I'm at my wits end on this...

 

cm230002_3-1715902757981.png

Chris

Categories:
I have the same question (0)
  • SudeepGhatakNZ Profile Picture
    14,394 Most Valuable Professional on at

    Interesting, I will take a look later today

     

  • cm230002 Profile Picture
    7 on at

    Thanks.

     

    I also do realize that I could achieve the end result with a series of conditions (if varFilterColumn = Territory then filter the Territory column else of varFilterColumn = Branch...etc.,) but I'm hoping to keep this flow more concise, and it seems that what I'm trying to do should be achievable, which is why I haven't gone down the Conditions path just yet.

  • Verified answer
    Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    Something like this?

    Chriddle_0-1715943378046.png

    Approvers

    [
    	{"FirstName": "Michael", "Email": "michael@example.com", "Branch": "US114", "Territory": "US114M", "Region": "NAMER"},
    	{"FirstName": "Daniel P", "Email": "daniel@example.com", "Branch": "US107", "Territory": "US107J", "Region": "NAMER"},
    	{"FirstName": "Charles", "Email": "charles@example.com", "Branch": "US114", "Territory": "US114H", "Region": "NAMER"},
    	{"FirstName": "John", "Email": "john@example.com", "Branch": "US114", "Territory": "US114H", "Region": "NAMER"}
    ]

     

    SingleLevel

    {"Level": "Branch", "Filter": "US114;US117"}

     

    Filter array

    From

    outputs('Approvers'

    Filter

    split(
    	outputs('SingleLevel')['Filter'],
    	';'
    )

    contains

    item()[outputs('SingleLevel')['Level']]

     

    Reesult

    [
     {
     "FirstName": "Michael",
     "Email": "michael@example.com",
     "Branch": "US114",
     "Territory": "US114M",
     "Region": "NAMER"
     },
     {
     "FirstName": "Charles",
     "Email": "charles@example.com",
     "Branch": "US114",
     "Territory": "US114H",
     "Region": "NAMER"
     },
     {
     "FirstName": "John",
     "Email": "john@example.com",
     "Branch": "US114",
     "Territory": "US114H",
     "Region": "NAMER"
     }
    ]
  • cm230002 Profile Picture
    7 on at

    Amazing, this worked 100%.

    I was able to address both dynamic values in the step where I define the level and filter properties (and was able to remove a variable further upstream because the split I was using is now in this step.

     

    cm230002_0-1715974633298.png

    Thank you so much!!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard