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 Platform Community / Forums / Power Apps / Removing blank record ...
Power Apps
Answered

Removing blank record from dynamically populated dropdown list

(0) ShareShare
ReportReport
Posted on by 57

Hello All,

 

I am trying to dynamically add "All" value to a dropdown list. The values for this dropdown list is coming from SharePoint List - Text column, which contains the user's name. The formula below works fine but I get a Blank record at end of the list which I am unable to remove. Can someone help me filter out the blank record from the final dropdown values?

 

With({choiceUserList: SortByColumns(Distinct(TotalList,AssignedToUser),"Result")},

ForAll(Sequence(CountRows(choiceUserList)+1),{Value: If(Value=1,"All",Last(FirstN(choiceUserList,Value-1)).Result)}))

 

Categories:
I have the same question (0)
  • GarethPrisk Profile Picture
    2,828 on at

    Instead of coding it so it is technically always getting the list of records, could you switch to a variable/collection model. In most scenarios, users won't need dynamic updates in a given app session.

    You could do something like:

    Clear(colAssignedToUsers);
    Collect(colAssignedToUsers,{Result: "ALL"}); // This single record needs to match the definition below
    Collect(colAssignedToUsers,SortByColumns(Distinct(TotalList,AssignedToUser),"Result")​);
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @AKB2021 

    Take a look at my video on adding All to any list.   I feel you might have already as this is pretty much the same formula that I designed in that video.  SO...your formula is good!  You just need to filter out the blanks.

     

    Specifically for your formula:

    With({choiceUserList: 
     SortByColumns(
     Filter(
     Distinct(TotalList, AssignedToUser), 
     !IsBlank(Result)
     ),
     "Result"
     )},
    
     ForAll(Sequence(CountRows(choiceUserList)+1, 0),
     {Value: If(Value=0,"All", Last(FirstN(choiceUserList,Value)).Result)}
     )
    )

     

    I hope this is helpful for you.

  • AKB2021 Profile Picture
    57 on at

    I already have a lot of collections which is kind of slowing down the app, hence thought of using dynamic approach here as users are assigning request to different user and then I had to refresh the entire collection each time they are making the change. 

  • AKB2021 Profile Picture
    57 on at

    I was filtering by encapsulating the complete with statement, which made the code crazy when it was just filtering within the With before ForAll. Thanks for your help!

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @AKB2021 

    The formula I provided is great for dynamic needs.  A lot of time your app will be updating sources and you want this reflected in your app immediately.  


    If you don't need the dynamic nature for your app, then you can skip the collection (always best to skip a collection unless you need the ability to create, edit or delete records in your app) and change your formula to the following and put it in the OnStart (or some other "initializing" action):

    Set(glbUserList,
     With({choiceUserList: 
     SortByColumns(
     Filter(
     Distinct(TotalList, AssignedToUser), 
     !IsBlank(Result)
     ),
     "Result"
     )},
    
     ForAll(Sequence(CountRows(choiceUserList)+1, 0),
     {Value: If(Value=0,"All", Last(FirstN(choiceUserList,Value)).Result)}
     )
     )
    )

    This will give you a variable that can then be used for your control Items property.  It will be the table and static.

     

    Bad news on collections is that you can't search for them like you can a variable.  Also, a collection has more overhead than a straight variable.  Variables can be anything you want, so in the above, it becomes a table that can be used anywhere you need that table.

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard