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 / Checking if values in ...
Power Apps
Answered

Checking if values in split string exist in table

(0) ShareShare
ReportReport
Posted on by 6

Essentially, a user provides a string into a textInput box, and after clicking a button, checks if any of the inputted values exists in a specified table. If the values does exist, it should append a value from the table to a new string. The result is then displayed to the users. 

The string would look like this: "Amy, Josh, John, Adam"

The table would look like this, and let's name it Sample_Data (Dataverse table): 

Name 1Name 2
ArnoldSmith
JoshMan
JoshCruise
AmyWoman
CharlesName

 

So the resulted string would look like this:

"Josh Man

Josh Cruise

Amy Woman"

 

I've started the below code, but maybe it's because I'm thinking about this like how I would approach this in things like C++ or Java, but I'm struggling to get it to translate in the onclick function in the button:

//userInput is the name of text box the user types the string in

Set(parseString, userInput.Text);

Set(parseTable, Split(parseString, ", "));

Set(resultString, "");

 

// Loop through each entry in the split string and append matching entries to the result table

ForAll(

    parseTable,

    If(

        !IsBlank(Filter(Sample_Data, 'Name 1' = Value)),

         ForAll(

         Filter(Sample_Data, 'Name 1' = Value),

                    Concat(resultString, Value.'Name 1', " ", Value.'Name 2', "\n" )

    ))

);

 

The reason for the double ForAll is because, in case the If fails and the value isBlank, I may still add the value to the string, but concat something like " - doesn't exist" to the value of the name. Any help would be appreciated, I'm sure I'm just thinking about this more like a traditional programmer and not like a PowerApps one. I'm still relatively new to PowerApps, so I'm sorry if I'm missing something simple.

Categories:
I have the same question (0)
  • Verified answer
    RogierE Profile Picture
    879 Moderator on at

    I guess PowerApps Fx is a bit less stict. 🙂 

    Good to know: 

    - PowerApps has collections and variables. Very close relatives, but collections are easier for manipulating tabular data

    - ForAll loops do not work with variables, so better use a collection for that

    - But Concats are less strict, so in fact you don't need the ForAll 😄

    - Best practice is to start variable names with var and collections with col. 

     

    So in short, and far shorter than you proposed,  your code could be:

    //userInput is the name of text box the user types the string in
    Set(varParseTable, Split(userInput.Text, ", "));

    // Loop through each entry in the split string and append matching entries to the result table
    Set(varResultString,Concat(Filter(Sample_Data,'Name 1' in varParseTable),'Name 1'&" "&'Name 2'&Char(13)))

     

    As the concat works on multiple rows, entering Josh will give you a string with 2 lines. And by using the 'in' statement in the Filter, I don't need to loop through the varParseTable. 

     

    Please LIKE the reply and ACCEPT it as the solution if the answer is what you were looking for.
    (to help me grow in community rank and help others find the solution)

  • fuentert94 Profile Picture
    6 on at

    I had no idea you can use the Concat function like that! This is exactly what I needed. I definitely was overthinking the problem. Thank you so much!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 366 Most Valuable Professional

#2
11manish Profile Picture

11manish 184

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 99 Super User 2026 Season 1

Last 30 days Overall leaderboard