Hello Powerapps Community!
I'm currently making an app that requires to be able to change a Datatable Source using a Combobox, I tried using Update context or a simple global variable. Unfortunatelly it dosen't change it since it's not a "Table" but a "Text"value.
Would any of you have an idea on how to do this, or at least some directions?
Thank you in advance for your time!
Solved! Go to Solution.
DataTables will display a collection (aka Table) in table format. So you would have to plug in the name of a collection or DataSource into the dataTable's Items property.
So if you have two DataSources "customers1" and "customer2", then you can create a comboBox (with multi-select turned off) or a listBox that has these values. You can do this one of two ways (that I know of):
1: Put something like this into your screen's OnVisible event to create a collection and then in your comboBox's Items property, plug in "myComboList" (without the quotes).
Clearcollect(myComboList, Table( {ListItem: "customers1"}, {ListItem: "customers2"}, ) )
2: If you don't want to have to deal with an in-memory collection, in the comboBox's Items list, simply plug in:
Table( {ListItem: "customers1"}, {ListItem: "customers2"}, )
In the DataTable's Items property, you can put "yourComboList.Selected.ListItem" (without the quotes). The problem I've found with dataTables is that it, like a dataForm, expects a static set of columns. That is, customers1 has a column "Full Name" and customers2 has two columns "First Name" and "Last Name", the dataTable will orient itself to the initial DataSet (let's say for eaxmple customers1) and throw a fit when you try to dynamically set it to customers2.
I hope others will chime in (to my benefit as well), but the only way I can see doing this is by throwing in some design magic. You would add columns where needed and then use ShowColumns to filter out columns that were different.:
ClearCollect(myCustomCollection1, ShowColumns(customers1 "FullName", "address", ...
) ); ClearCollect(myCustomCollection2, ShowColumns( AddColumns(customers2, "fullName", firstName & ", " & lastName, ... ), "FullName", "address", ... )
DataSet customers1 uses its original/native name of "fullName", while customers2 has a column added for "fullName" and then a ShowColumns command filters out the no-longer-used firstName and lastName.
Now, using the example above regarding the comboBoxes, you can set your comboBox's choices to include "myCustomCollection1" and "myCustomCollection2". Now when you select the custom collections, the table will update dynamically using the standardized column names. I hope that helps.
Based on your picture, it looks like your myCustomTable collection (which presumably used a ClearCollect command to create) collected a single column called "Unite". You can double-check your collection by clicking on View > Collection > myCustomTable. Make sure the collection was collected correctly. You may also want to double-check to make sure that your Excel dataSource is correct as well--that is, having more than one column.
The problem I've found with dataTables is that--as far as I know--you cannot dynamically change its column scheme during run-time. I've had to select the columns during edit-mode using a standardized format and then use code and temporary collections to update the data. In some ways, you using the myCustomTable is doing that already. What you would further do is:
ClearCollect(myCustomTable, Table({FullName: Blank(), Address: Blank(), Age: 0})There is no need to worry about the dummy-data since when you ClearCollect later on, it will clear out this data. The purpose of this is to create the collection's columns and datatype scheme.
If(ComboBox1.Selected.Nom_Liste="xyz", ClearCollect(myCustomTable, ShowColumns( AddColumns(xyz, "FullName", FirstName & ", " & LastName"), FullName, Address, Age ) ) If(ComboBox1.Selected.Nom_Liste="abc", ClearCollect(myCustomTable, ShowColumns( AddColumns(abc, "Address", Street & ", " & City & " " & State & " " & ZIP), FullName, Address, Age ) )
I suppose if you want to show different column schemes, you could use two different tables and assign them different column schemes (during edit-mode) and then use code to turn one visible and the other invisible. The user-experience would assume it was the same table.
And to answer your question, creating a collection (e.g. ClearCollect, Collect, Clear) and removing/clearing it does not affect your datasource (e.g. your Excel spreadsheet). It creates a temporary, in-memory object to hold the data and all subsequent references to the temporary collection will affect only the temporary collection. So using AddColumns and ShowColumns will not add columns or erase columns on your spreadsheet, if that's what you are asking.
Let's take a step back then. It sounds like you may have to rethink your design, but let me cover some basics that I've learned so far:
From my perspective, you would only group datasources (e.g. in a datatable) in PowerApps if they are part of the same class of information (e.g. data all related to people... or data all related to products... etc.). If they are different classes of information (e.g. one about people and another about products) then you ought to consider different tables (can make one visible while the others are invisible; overlapping them will make them look like the same table) or even different screens.
To update your dataSource, you can use the Patch, Update, UpdateIf, Remove, RemoveIf commands while referencing the datasource. If you program, then a ClearCollect'ed collection is not a reference to an object. It's more like a clone of the object, but you can still use them to affect your true, datasource (i.e. real changes to your spreadsheet). For example, If you end up using a temporary collection (e.g. for the purpose of adding columns, joining data from another datasouce, etc.), instead of patching temporaryListeUniteCollection, you would patch listeunite. And then you would invoke a ClearCollect to refresh your temporary collection.
I hope that helps. I feel like I haven't been able to give you a solution for your specific request, but hopefully you have some avenues to look at. My personal opinion and experience is that 9 times out of 10, when it gets too complicated, I'm usually overthinking it and there's probably an easier solution if I rethink the design.
DataTables will display a collection (aka Table) in table format. So you would have to plug in the name of a collection or DataSource into the dataTable's Items property.
So if you have two DataSources "customers1" and "customer2", then you can create a comboBox (with multi-select turned off) or a listBox that has these values. You can do this one of two ways (that I know of):
1: Put something like this into your screen's OnVisible event to create a collection and then in your comboBox's Items property, plug in "myComboList" (without the quotes).
Clearcollect(myComboList, Table( {ListItem: "customers1"}, {ListItem: "customers2"}, ) )
2: If you don't want to have to deal with an in-memory collection, in the comboBox's Items list, simply plug in:
Table( {ListItem: "customers1"}, {ListItem: "customers2"}, )
In the DataTable's Items property, you can put "yourComboList.Selected.ListItem" (without the quotes). The problem I've found with dataTables is that it, like a dataForm, expects a static set of columns. That is, customers1 has a column "Full Name" and customers2 has two columns "First Name" and "Last Name", the dataTable will orient itself to the initial DataSet (let's say for eaxmple customers1) and throw a fit when you try to dynamically set it to customers2.
I hope others will chime in (to my benefit as well), but the only way I can see doing this is by throwing in some design magic. You would add columns where needed and then use ShowColumns to filter out columns that were different.:
ClearCollect(myCustomCollection1, ShowColumns(customers1 "FullName", "address", ...
) ); ClearCollect(myCustomCollection2, ShowColumns( AddColumns(customers2, "fullName", firstName & ", " & lastName, ... ), "FullName", "address", ... )
DataSet customers1 uses its original/native name of "fullName", while customers2 has a column added for "fullName" and then a ShowColumns command filters out the no-longer-used firstName and lastName.
Now, using the example above regarding the comboBoxes, you can set your comboBox's choices to include "myCustomCollection1" and "myCustomCollection2". Now when you select the custom collections, the table will update dynamically using the standardized column names. I hope that helps.
Thanks for your reply, I forgot to add in a couple of details:
-I'm using Excel Tables and these are the ones i want shown in the Datatable
-The ComboBox is using another Table which contains all the names of the different Tables I want shown in the Datatable.
From what I understood I need either to create a collection or setup the values manually in the ComboBox Items. The problem here is you declare them as "Text" values so the DataTable's Items cannot process it.
Basically what I'm looking for is to manipulate a "Table" value. I tried using "yourComboList.SelectedItems.ListItem" the issue here is that it will only show me the name of the selected item in the DataTable. The second thing i need to know (assuming that the Item of the DataTable is set correctly) is to add names of columns in the DataTable (like you would select them with the graphical interface) I can't see where it is being set.
After trying your suggestions they unfortunatelly do not work for me...
Thank you for your help!
I think I may be misunderstanding what you are attempting to do. If you have a few screenshots, that may help clarify things.
On this first screenshot you can see that I set the Items of my ComboBox to be "listeliste" which is an excel table containing the names of other excel tables that i want to see on the Datatable at the right of the Combobox
On the Second Screenshot you can see that I'm setting the Items as "ComboBox1.SelectedItems.Nom_Liste" (Nom_Liste being the name of the only column in listeliste). In theory it should get the selected ITEMS and therefor use them as "Table" values.
In the third screenshot you can see what results i expect when using the combobox to choose "listeunite" which contains various units and being able to view then in the DataTable.
Unfortunatelly this does not work, the Datatable will only show me the name of "listeunite" in the DataTable (and this only after choosing to show "Nom_Liste" in the properties of the Datatable.
I hope this will help you understand where help is needed,
Thank you in advance!
You are right. I just tested it and it is passing the literal "listeunite" instead of the actual dataSource (or collection) listeunite.
I thought of 2 possible ways to address this:
1. First Option: On ComboBox1.OnChange event, create an if statement that collects a standardized collection:
If(ComboBox1.Selected.Nom_Liste="xyz", ClearCollect(myCustomTable, xyz), If(ComboBox1.Selected.Nom_Liste="abc", ClearCollect(myCustomTable, abc) ))
*I noticed that you used the ComboBox1.SelectedItems.Nom_Liste. The SelectedItems infers that you are using Allow multiple selections. I'm presuming that you mean to allow only 1 selection, so you would switch this option to Off and use the property ComboBox1.Selected.Nom_Liste instead.
And then you would set DataTable1.Items to myCustomTable. Now, it should resolve as the actual collection and not the literal text.
2. Second Option: On DataTable1.Items, you can do something like this:
If(ComboBox1.Selected.Nom_Liste="xyz", xyz, If(ComboBox1.Selected.Nom_Liste="abc", abc ))
This approach would be very similar, but instead of creating the collection as an event on the comboBox, you are creating the collection from the dataTable.
I encourage you to keep looking for other solutions, this is how I would solve this issue (my preference would be option #1, so that I have some liberty to manipulate the collection (e.g. Collect to append more data, etc.). I hope this helps.
I tested out option 1 and it works great! The only thing that needs to be done is to actually be able to select de the field displayed in the DataTable:
We can see that the DataTable's source is properly set but the field "Unite" which shows the data is not selected and therefore the data is not visible.
Another concern I have is by putting the Table in a Collection if we chage/add to the collection will it also update the Table in the Excel file?
I had already tried using something like your second option but it is simply not feasable:
On the second screenshot you can see on the right it takes both of the Tables as the source. As I understand it, in the Items field of the DataTable (this works perfectly on other Items from other Objects but not on DataTables), it will look through to find a "Table" type value regardless of conditions.
Based on your picture, it looks like your myCustomTable collection (which presumably used a ClearCollect command to create) collected a single column called "Unite". You can double-check your collection by clicking on View > Collection > myCustomTable. Make sure the collection was collected correctly. You may also want to double-check to make sure that your Excel dataSource is correct as well--that is, having more than one column.
The problem I've found with dataTables is that--as far as I know--you cannot dynamically change its column scheme during run-time. I've had to select the columns during edit-mode using a standardized format and then use code and temporary collections to update the data. In some ways, you using the myCustomTable is doing that already. What you would further do is:
ClearCollect(myCustomTable, Table({FullName: Blank(), Address: Blank(), Age: 0})There is no need to worry about the dummy-data since when you ClearCollect later on, it will clear out this data. The purpose of this is to create the collection's columns and datatype scheme.
If(ComboBox1.Selected.Nom_Liste="xyz", ClearCollect(myCustomTable, ShowColumns( AddColumns(xyz, "FullName", FirstName & ", " & LastName"), FullName, Address, Age ) ) If(ComboBox1.Selected.Nom_Liste="abc", ClearCollect(myCustomTable, ShowColumns( AddColumns(abc, "Address", Street & ", " & City & " " & State & " " & ZIP), FullName, Address, Age ) )
I suppose if you want to show different column schemes, you could use two different tables and assign them different column schemes (during edit-mode) and then use code to turn one visible and the other invisible. The user-experience would assume it was the same table.
And to answer your question, creating a collection (e.g. ClearCollect, Collect, Clear) and removing/clearing it does not affect your datasource (e.g. your Excel spreadsheet). It creates a temporary, in-memory object to hold the data and all subsequent references to the temporary collection will affect only the temporary collection. So using AddColumns and ShowColumns will not add columns or erase columns on your spreadsheet, if that's what you are asking.
My "listeunite" contains only one column "Unite" so this part is normal.
The fact that a collection has no affect on the Excel table is problematic for me as the goal is to:
Select a Table with ComboBox --> Visualise data in Datatable --> Select line to edit/remove or add a new one.
The proplem I had was that i couldn't dynamically set up something like this
Select Table with Combobox --> Datatable shows Table with all Columns
So we're coming back to the core problem which is being able to dynamically change a Data Table source using Excel Tables with the goal to Edit/remove or create records in the Excel Tables using a form which will also change it's source depending on the ComboBox.
I hope this time you can see what the goal is.
Thanks for your help
Let's take a step back then. It sounds like you may have to rethink your design, but let me cover some basics that I've learned so far:
From my perspective, you would only group datasources (e.g. in a datatable) in PowerApps if they are part of the same class of information (e.g. data all related to people... or data all related to products... etc.). If they are different classes of information (e.g. one about people and another about products) then you ought to consider different tables (can make one visible while the others are invisible; overlapping them will make them look like the same table) or even different screens.
To update your dataSource, you can use the Patch, Update, UpdateIf, Remove, RemoveIf commands while referencing the datasource. If you program, then a ClearCollect'ed collection is not a reference to an object. It's more like a clone of the object, but you can still use them to affect your true, datasource (i.e. real changes to your spreadsheet). For example, If you end up using a temporary collection (e.g. for the purpose of adding columns, joining data from another datasouce, etc.), instead of patching temporaryListeUniteCollection, you would patch listeunite. And then you would invoke a ClearCollect to refresh your temporary collection.
I hope that helps. I feel like I haven't been able to give you a solution for your specific request, but hopefully you have some avenues to look at. My personal opinion and experience is that 9 times out of 10, when it gets too complicated, I'm usually overthinking it and there's probably an easier solution if I rethink the design.
Dear Community Members, We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd. During this period, members will not be able to Kudo, Comment, or Reply to any posts. On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities. What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!
We are excited to announce the Summer of Solutions Challenge! This challenge is kicking off on Monday, June 17th and will run for (4) weeks. The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities. Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”) - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024 Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods. You must enter into each weekly Entry Period separately. How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different. Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers. At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing. Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner. A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random. Individuals will be contacted before the announcement with the opportunity to claim or deny the prize. Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners. Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event. ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE** Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08 23 @WarrenBelz 31 @DBO_DV 10 @Amik 19 AmínAA 6 @mmbr1606 12 @rzuber 4 @happyume 7 @Giraldoj 3@ANB 6 (tie) @SpongYe 6 (tie) Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08 10@WarrenBelz 25 @DBO_DV 6@mmbr1606 14 @AmínAA 4 @Amik 12 @royg 3 @ANB 10 @AllanDeCastro 2 @SunilPashikanti 5 @Michaelfp 2 @FLMike 5 @eduardo_izzo 2 Meekou 2 @rzuber 2 @Velegandla 2 @PowerPlatform-P 2 @Micaiah 2 Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27 Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8 SunilPashikanti8
On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners. The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights. Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.
We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for. We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer. Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together. Here's to new beginnings and endless possibilities! If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport. To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages