web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / how to create a table ...
Power Apps
Answered

how to create a table data? which can be stored within app.

(0) ShareShare
ReportReport
Posted on by 288

Hello,

 

What is a good way to create a table data within PowerApps (Canvas), I need it to contain only a few records in form of a email.

Should I use collections, or components or something third? I would avoid creating another Sharepoint list for that purpose.

 

Can you please help me out and show some example of how it's done? 

Id name it like "ManagerEmails" and have structure like this:

NidjoJohnny22_0-1673364294635.png

 

and how do I loop through those records?

 

Thanks everyone! 

 

- Nikola

Categories:
I have the same question (0)
  • Michael_Scott Profile Picture
    106 on at

    first off if you want the list to be the same every time the app is started I would use clearcollect instead of collect. if you use collect you might get duplicates depending on where your code is that is doing the collecting.

     

    You could try using something like this as well: 

    ClearCollect(colOptions, {Label="Name1",Value="Value1"},{Label="Name1",Value="Value1"},{........});

     

    Hopefully this helps!

     

  • AlexBakerWong Profile Picture
    79 on at

    Hi,

     

    Is this static data? Data that will not change? Then there are 2 options:

    1. Use the collections as in the screenshot you shared or
    2. Upload an Excel file in the Data Sources

    If you are looking at dynamic data there are 2 options:

    1. If you are storing a list of people, use groups (SharePoint or Active Directory)
    2. If not a list of people use data location where you have the rest of your data.

    Thanks,

    Alex

     

    Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful because this can help others.

    If I have helped, feel free to donate the Power Platform Duo coffee money: https://www.buymeacoffee.com/thePPDuo Otherwise follow me on:

    LinkedIn: https://uk.linkedin.com/in/alexandrebaker 
    YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg

  • NidjoJohnny22 Profile Picture
    288 on at

    hi, it's a static data for sure, to be present each time app runs. my last two options are collections, but I dont quite understand its usage (does it take data from textlabels, or I can pre-define collection value)? 

     

    what's clearCollect function's role?

     

    if I have some input value like User().Email, that is checked from user that is currently using the app, how can I use ot to loop through the pre-hard-coded collection and check whether it is there (true/false outcome)?

     

    any simple example like that?

     

    sorry for asking such basic questions, I'm lost in looping through table and other data structure functions, it's all mixed up in my head...

    The reason I ask is bcz I find collections to have significantly easier access to data than Lists with confusing functions/methods.

  • Verified answer
    Michael_Scott Profile Picture
    106 on at

    A questions difficulty is dependent on the one asking it and your are working with something new to you so don't feel bad asking anything! People are here to help in any way we can!

     

    To start a collection in powerapps is a list or array type data structure that we use to store data locally that we dont want to fetch multiple times or dont want to store to begin with. There are 3 ways to add to a collection generally these being Patch, Collect, and ClearCollect.

     

    Patch Function - this is used to ADD A NEW ITEM to a list OR EDIT AN EXISTING ITEM in a list

    Collect - this is used to ADD ITEMS ONLY and will simple slap this item on the end of the list

    ClearCollect - this is used to first clear the list to make sure it is blank, then Collects the item to the now empty list the same was Collect would above

     

    For this we just use clear collect in order to make sure that we are creating duplicates of the values. What can happen is a powerapp function could return the first item it matched with but that could be an out dated item and it wasnt removed when the new version of that item was added to the list. This is prevented by using ClearCollect when you can.

     

    Collections can also be hardcoded and static or grab values dynamically from a user input field of some type.

    ClearCollect(localEmployees, Employees) -> this copies the SP list Employees to a local collection in the powerapps called local Employees

    ClearCollect(localEmployees, {FirstName: TextInput1.Text, LastName: TextInput1_1.Text, etc...}) -> This takes the values input by a user into text input fields, creates an object with them and then stores that object in localEmployees collection

    ClearCollect(localEmployees, {FirstName: "Mike", LastName: "Jones", etc...}) -> This will create this list with the hardcoded values

     

    Last question was how to check if a User().Email value is already in the list or not. Here is how you would do that in the powerapp...

    Set(results, Lookup(listName, Email = User().Email)) -> this will search for an entry in the list (or collection) that has an email that matches User().Email and if it exists will return that item and store it in a global variable called results. You can then access this items properties by using the dot operator like results.FirstName etc.

     

    This can also be used in ways such as this...

    If(IsBlank(LookUp(collectionName, Email = User().Email)), Navigate(CreateNewEntryPage), Navigate(ShowEntryPage));

    This will look for a matching email, return one if it exists and return blank if it doesnt find that entry. After it does that it will either navigate to the createnewentrypage if it was blank to allow a user to create their user or to the showentrypage if the user alrady exists where you could show your list fields and/or edit them.

     

    This was alot but I hope it helps! good luck and if this solves your issues please mark it as the solution.

  • NidjoJohnny22 Profile Picture
    288 on at

    Wow, thanks @Michael_Scott for the very good explanation for each individual function/method!

    Okay, I've managed so far to check whether the User's email exists in a Sharepoint list (made a list just for that - work good for now). Will change to collection over time.

     

    so basically, the info I didn't know before I've read this post and I can conclude now that collection can be hardcoded within text input's Text property in Power Apps (Canvas), so I can pull data from there! 

    That is good because I don't have to look for some Screen properties or such, I have a very solid data storage (Text input / example: Textinput1.Text = collection object { "key: value", "key2: value2"}...

     

    that was my assumption due to this section of the post:

    "ClearCollect(localEmployees, {FirstName: TextInput1.Text, LastName: TextInput1_1.Text, etc...}) -> This takes the values input by a user into text input fields, creates an object with them and then stores that object in localEmployees collection

    ClearCollect(localEmployees, {FirstName: "Mike", LastName: "Jones", etc...}) -> This will create this list with the hardcoded values"

     

    I don't know yet how to pull data from Textinput.Text property when it's in object form, but I assume it can be achieved using the Table functions?

     

    Will do it, right now I'm stuck on Flow so I need to stop doing "infinite loops" then I get back to this! 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard