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 : VV4XM2i5etnWDYC2pju6R8
Power Apps - Building Power Apps
Answered

Use Set Function to Assign Multiple Values to One Variable

Like (1) ShareShare
ReportReport
Posted on 9 Jul 2024 15:20:30 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
    )
)
I have the same question (0)
  • hhuynhfm Profile Picture
    on 09 Jul 2024 at 19:27:46
    Re: Use Set Function to Assign Multiple Values to One Variable

    Thank you so much!! This worked 😊

  • Verified answer
    Sam_Fawzi Profile Picture
    516 Super User 2025 Season 2 on 09 Jul 2024 at 19:21:23
    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 09 Jul 2024 at 19:14:41
    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
    Sam_Fawzi Profile Picture
    516 Super User 2025 Season 2 on 09 Jul 2024 at 15:49:40
    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 Moderator on 09 Jul 2024 at 15:46:35
    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

Responsible AI policies

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

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 892 Most Valuable Professional

#2
Power Apps 1919 Profile Picture

Power Apps 1919 356

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 310 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading complete