cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lchen26
Frequent Visitor

Selecting Column Names to sort by using ntural language radio button choices

Hi folks, hope you're doing alright,

 

I'm trying to create a PowerApp that sorts through a list of equipment with a couple data columns [Asset Tag, Assigned Employee, Seat Number, etc]

 

I've been doing pretty well, but I'm trying to expand our options so users can choose which data column they can have the BrowseScreen sorted by. To this end, I've created a Choice Screen with Radio Buttons, populated it with my column names, set a default section, etc.

 

lchen26_1-1632411175906.png

 

From here, I updated my SortByColumns function to search by the Radio Button Choice value. Syntax checks out, but I'm finding this only works for columns with names that don't contain spaces. Seems I made the cardinal sin of creating column names that contain spaces so the names all have the x0020 artifacts ("Asset_x0020_Tag","Assigned_x0020_Employee", etc).

 

lchen26_2-1632411875079.png

 

So now, obviously, the function can't reconcile the true column name with its natural language equivalent. (my work with the Search() function should have tipped me off this would be a problem). How can I compensate for this while still ensuring my radio button choices don't need to include the funky characters?

 

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
C-Papa
Super User
Super User

hi, with the radio OnChange property you can create a formula that applies the correct column header. 

 

see below for an example:

 

RadioChoiceSort1 OnChange =

Set(var_sort,

          Switch(RadioChoiceSort1.Selected.Value,

          "Title","Title",

          "Asset Tag","Asset_x0020_Tag",

          "Equipment Type","Equipment_x0020_Type",

          etc etc))

 

then change the sort in the gallery from RadioChoiceSort1.Selected.Value to var_sort

 

You might also have to set a default value so the sort works when the screen loads, set the screen on visible property to Set(var_sort,"Title")

 

Remember, you cannot use calculated columns or choice columns to sort, you will need to use the addcolumns function to get round  this

View solution in original post

zmansuri
Super User
Super User

Instead of HardCoding names for Radio Button. Set a collection on App.OnStart like this:

ClearCollect(colTest3,{Name:"Asset Tag",Value:"Asset_x0020_Tag"})

For Radio button Item property use this:

Coltest3.Name

And for sorting code use this:

Radio1.Selected.Value

View solution in original post

5 REPLIES 5
C-Papa
Super User
Super User

hi, with the radio OnChange property you can create a formula that applies the correct column header. 

 

see below for an example:

 

RadioChoiceSort1 OnChange =

Set(var_sort,

          Switch(RadioChoiceSort1.Selected.Value,

          "Title","Title",

          "Asset Tag","Asset_x0020_Tag",

          "Equipment Type","Equipment_x0020_Type",

          etc etc))

 

then change the sort in the gallery from RadioChoiceSort1.Selected.Value to var_sort

 

You might also have to set a default value so the sort works when the screen loads, set the screen on visible property to Set(var_sort,"Title")

 

Remember, you cannot use calculated columns or choice columns to sort, you will need to use the addcolumns function to get round  this

View solution in original post

zmansuri
Super User
Super User

Instead of HardCoding names for Radio Button. Set a collection on App.OnStart like this:

ClearCollect(colTest3,{Name:"Asset Tag",Value:"Asset_x0020_Tag"})

For Radio button Item property use this:

Coltest3.Name

And for sorting code use this:

Radio1.Selected.Value

View solution in original post

Not sure what the advantage of doing this is because you are still hard coding it to a collection, just in a different place. If something changes you will still need to edit the app to update the changes, same same but different!

While creating the collection trim out the _x0020_ and insert a space, sorted.

lchen26
Frequent Visitor

thanks to both of you! I'll explore these two solutions and see what works best

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,607)