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 / Startswith against table
Power Apps
Answered

Startswith against table

(0) ShareShare
ReportReport
Posted on by 364

Morning all,

 

I'm creating a glossary gallery that can be filtered to show items based on what they start with. As space is at a premium, I've grouped the letters to ranges, as below:

 

ClearCollect(alph,
 {Letter: "A", Grp: "A-F"},
 {Letter: "B", Grp: "A-F"},
 {Letter: "C", Grp: "A-F"},
 {Letter: "D", Grp: "A-F"},
 {Letter: "E", Grp: "A-F"},
 {Letter: "F", Grp: "A-F"},
 {Letter: "G", Grp: "G-L"},
 {Letter: "H", Grp: "G-L"},
 {Letter: "I", Grp: "G-L"},
 {Letter: "J", Grp: "G-L"},
 {Letter: "K", Grp: "G-L"},
 {Letter: "L", Grp: "G-L"},
 {Letter: "M", Grp: "M-R"},
 {Letter: "N", Grp: "M-R"},
 {Letter: "O", Grp: "M-R"},
 {Letter: "P", Grp: "M-R"},
 {Letter: "Q", Grp: "M-R"},
 {Letter: "R", Grp: "M-R"},
 {Letter: "S", Grp: "S-X"},
 {Letter: "T", Grp: "S-X"},
 {Letter: "U", Grp: "S-X"},
 {Letter: "V", Grp: "S-X"},
 {Letter: "W", Grp: "S-X"},
 {Letter: "X", Grp: "S-X"},
 {Letter: "Y", Grp: "Y-#"},
 {Letter: "Z", Grp: "Y-#"},
 {Letter: "#", Grp: "Y-#"}
 )
)

 

There are buttons that correspond to the letter ranges and the gallery will be filtered to show all letters within the selected range. Now, I can get it to work this way, with Table1 being my glossary data source:

 

If(
 suggested.Title = "Glossary", 
 Switch(true,
 glossarySortOrder = "A-F", Filter(Table1, 
 StartsWith(Acronym, "A") || 
 StartsWith(Acronym, "B") || 
 StartsWith(Acronym, "C") || 
 StartsWith(Acronym, "D") || 
 StartsWith(Acronym, "E") || 
 StartsWith(Acronym, "F")),
 glossarySortOrder = "G-L", Filter(Table1, 
 StartsWith(Acronym, "G") || 
 StartsWith(Acronym, "H") || 
 StartsWith(Acronym, "I") || 
 StartsWith(Acronym, "J") || 
 StartsWith(Acronym, "K") || 
 StartsWith(Acronym, "L")),
 glossarySortOrder = "M-R", Filter(Table1, 
 StartsWith(Acronym, "M") || 
 StartsWith(Acronym, "N") || 
 StartsWith(Acronym, "O") || 
 StartsWith(Acronym, "P") || 
 StartsWith(Acronym, "Q") || 
 StartsWith(Acronym, "R")),
 glossarySortOrder = "S-X", Filter(Table1, 
 StartsWith(Acronym, "S") || 
 StartsWith(Acronym, "T") || 
 StartsWith(Acronym, "U") || 
 StartsWith(Acronym, "V") || 
 StartsWith(Acronym, "W") || 
 StartsWith(Acronym, "X")),
 glossarySortOrder = "Y-#", Filter(Table1, 
 StartsWith(Acronym, "Y") || 
 StartsWith(Acronym, "Z") || 
 IsNumeric(Acronym)),
 Table1), 
 Filter(
 Table1,
 suggested.Title in Trim(Split(Category,";"))))

 

 But i realise this means my collections only really needs to contain my five letter groups and not the corresponding letter. So what I need is it to compare the start of the Acronym against the letters within the selected group. I've managed to get this to work:

 

 glossarySortOrder = "A-F", Filter(Table1, 
 StartsWith(Acronym, LookUp(alph, Grp = "A-F").Letter)),

 

But this just returns, for example, any item that begins with A. 

 

Is it possible to have StartsWith compare against a range of values, or am I barking up the wrong tree here?

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @EpicTriffid :

    Please modify the Filter formula to:

     

    Filter(
     Table1,
     Sum(
     ForAll(
     Filter(
     alph,
     Grp = "A-F"
     ),
     If(
     StartsWith(
     Acronym,
     Letter
     ),
     1,
     0
     )
     ),
     Value
     ) > 0
    )

     

     I've made a test for your reference:

    1\My Table1:

     

    ClearCollect(
     Table1,
     {Acronym:"AXXX"},
     {Acronym:"CXXXX"},
     {Acronym:"DXXXX"},
     {Acronym:"EXXXXX"},
     {Acronym:"VXXXXX"},
     {Acronym:"XXXX"},
     {Acronym:"GXXXXX"},
     {Acronym:"FXXXXX"}
    )

     

    2\Add a data table control and set it's Items property to:

     

    Filter(
     Table1,
     Sum(
     ForAll(
     Filter(
     alph,
     Grp = "A-F"
     ),
     If(
     StartsWith(
     Acronym,
     Letter
     ),
     1,
     0
     )
     ),
     Value
     ) > 0
    )

     

    1.PNG

    Best Regards,

    Bof

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 547

#2
WarrenBelz Profile Picture

WarrenBelz 444 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard