Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Use Set Function to Assign Multiple Values to One Variable

(1) ShareShare
ReportReport
Posted on by

Hello!

 

I have a function in my app that filters a gallery based on a text value of an item and the user's email. I was wondering if it is possible to assign multiple values to one variable for each email. For example, if my email is person1@gmail.com, can I make it so that my gallery displays values where the gbl_filter_value is both "Pending L1 Approval" and say, "Submitted"? 

 

Switch(
    User().Email,
    "person1@gmail.com",
    Set(
        gbl_filter_value,
        "Pending L1 Approval"
    ),
    "person2@gmail.com",
    Set(
        gbl_filter_value,
        "Pending L2 Approval"
    ),
    "person3@gmail.com",
    Set(
        gbl_filter_value,
        "Pending L3 Approval"
    )
)
 
 
 
Items property for said gallery:
SortByColumns(
    Filter(
        'Dashboard',
        'Approval Status'.Value = gbl_filter_value,
        StartsWith(
            Title,
            TextSearchBox1_1.Text
        ) || StartsWith(
            'Date Submitted',
            TextSearchBox1_1.Text
        ) || StartsWith(
            'Version #',
            TextSearchBox1_1.Text
        ) || StartsWith(
            'AFE Number',
            TextSearchBox1_1.Text
        )
    ),
    "Title",
    If(
        SortDescending1,
        SortOrder.Descending,
        SortOrder.Ascending
    )
)
  • hhuynhfm Profile Picture
    on at
    Re: Use Set Function to Assign Multiple Values to One Variable

    Thank you so much!! This worked 😊

  • Verified answer
    SamFawzi-SmartSolutions Profile Picture
    258 Super User 2025 Season 1 on at
    Re: Use Set Function to Assign Multiple Values to One Variable

    Sorry, here is the updated Gallery Item property:

    SortByColumns(
     Filter(
     'Dashboard',
     'Approval Status'.Value in gbl_filter_values.Value && // Correct the comparison here
     (
     StartsWith(Title, TextSearchBox1_1.Text) ||
     StartsWith('Date Submitted', TextSearchBox1_1.Text) ||
     StartsWith('Version #', TextSearchBox1_1.Text) ||
     StartsWith('AFE Number', TextSearchBox1_1.Text)
     )
     ),
     "Title",
     If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
    )

     

    Give it a try and let me know!

  • hhuynhfm Profile Picture
    on at
    Re: Use Set Function to Assign Multiple Values to One Variable

    Hello @samfawzi_acml

     

    Thanks for your reply! The first function is working but when I try the Items property for my gallery, it gives me the error "Incompatible types for comparison. These types can't be compared: Text, Table". How can I fix this?

  • Verified answer
    SamFawzi-SmartSolutions Profile Picture
    258 Super User 2025 Season 1 on at
    Re: Use Set Function to Assign Multiple Values to One Variable

    Hey @hhuynhfm ,

    Yes, it is possible to filter a gallery based on multiple values for a single user. Instead of setting gbl_filter_value to a single value, you can create a collection of values. Then, you can filter the gallery to display items that match any of the values in this collection. Here's how you can do it:

     

    Update the Switch Statement:

     

    Switch(
     User().Email,
     "person1@gmail.com",
     ClearCollect(
     gbl_filter_values,
     "Pending L1 Approval",
     "Submitted"
     ),
     "person2@gmail.com",
     ClearCollect(
     gbl_filter_values,
     "Pending L2 Approval"
     ),
     "person3@gmail.com",
     ClearCollect(
     gbl_filter_values,
     "Pending L3 Approval"
     )
    )

     

     

     

    Updated Gallery Items Property:

     

    SortByColumns(
     Filter(
     'Dashboard',
     'Approval Status'.Value in gbl_filter_values &&
     (
     StartsWith(Title, TextSearchBox1_1.Text) ||
     StartsWith('Date Submitted', TextSearchBox1_1.Text) ||
     StartsWith('Version #', TextSearchBox1_1.Text) ||
     StartsWith('AFE Number', TextSearchBox1_1.Text)
     )
     ),
     "Title",
     If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
    )

     

     

     

    Hope this will help!

    Cheers

  • ivan_apps Profile Picture
    2,187 Super User 2025 Season 1 on at
    Re: Use Set Function to Assign Multiple Values to One Variable

    You could change your variable to be an Table variable and add multiple items to the array depending on the email. That way your can iterate through it or use the "in" operator to filter your gallery on multiple items.

     

    Set(gbl_filter_value, Table("Pending L1 Approval" , "Submitted"))

     

    your filter criteria can then be something like:

    'Approval Status'.Value in gbl_filter_value

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,017 Most Valuable Professional

Leaderboard