Hey all,
i am trying ot achieve to create a collection for my on start property of my canvas app. I have an employee table with names and a table with expertises looking like shown below. The tables have a many to many relationship.
NameTable
Name | .... | |
Max | max@gmail.com | |
Anna | anna@gmail.com | |
.... |
Expertise Table
Category | Expertise |
Software | AutoCad |
Software | Powerapps |
Software | Maptek |
Processing | Planning |
Processing | Design |
Consulting | Onboarding |
My desired outcome as a collection is this:
Name | Category | Expertise String |
Max | Software | AutoCad | PowerApps | Maptek |
Max | Processing | Planning |
Anna | Software | AutoCad | PowerApps |
Anna | Consulting | Onboarding |
... |
The idea is to have a collection that shows all names with all their expertises. A simple version like this would also do for me, however the above is prefered.
Name | Expertise |
Max | AutoCad |
Max | PowerApps |
Max | Maptek |
Max | Planning |
Anna | AutoCad |
Anna | PowerApps |
... |
I have no idea how to get a collection with all records from the name table. Usually i go and select a name in a gallery and then just have a second gallery that uses a function like gallery1.selected.Expertise but this will only show it for one person of course.
Any help towards those many to many relationships are highly welcomed.
Solved! Go to Solution.
So caveat emptor on using experimental features. However turning on the "Record Scope" feature does do the trick. It is not straight forward though - despite this feature "allowing table operations", the fact remains (per my previous post) that the relationship doesn't manifest as a column we can reference, so we can't just simply ungroup it.
I am not saying this is the perfect answer, but it works.
This entire solution is based on Concat() being the only function I could get to actually reference the intersect table property of the NameTable datasource (there may be others).
Note to produce the data in the intersect table, you only need 3 steps. The 2 additional steps are only to group by category, per your original requirement. Here's the break down of the 5 steps, you could nest these but it doesn't make it easy to understand:
//Collect the related data as a nested delimited list
ClearCollect(col_Result_A, ForAll(NameTables As T1, {Name: T1.Name, xExpertise: Concat(T1.ExpertiseTables, Category & ";" & Expertise, "|")}));
Produces:
//Initiliase the next collection, we will use it as a Collect-only in the ForAll
ClearCollect(col_Result_B, Blank());
//Split the outer delimited values onto their own rows, collect in the inner collection col_Result_B, col_temp is just a dummy
ClearCollect(col_temp, ForAll(col_Result_A, ForAll(Split(xExpertise, "|"), Collect(col_Result_B, {Name:Name, xSplit: Value}))));
Produces (the Value column comes from initialising with Blank()):
//Split the category/expertise pairs into their own columns
ClearCollect(col_Result_C, ForAll(col_Result_B, {Name: Name, Category: First(Split(xSplit, ";")).Value, Software: Last(Split(xSplit, ";")).Value}));
Produces:
//Group expertise by name/category
ClearCollect(col_Result_D, GroupBy(col_Result_C, "Name", "Category", "Expertise"));
Produces:
//Create pipe delimited list of expertise, now by the groupings
ClearCollect(col_Result_Final, ForAll(col_Result_D, {Name: Name, Category: Category, Expertise: Concat(Expertise, Software, "|")}) );
Produces:
Use this collection as the Items property of a table, and you have your original requirement.
Hi @barbossa_94 ,
where is the information that says e.g. "Max is related to Processing/Planning"?
The "desired outcome" collection somehow knows this, but it can't be determined from only the Name and Expertise tables. Many-to-Many relationships have a table in between the 2 related entities.
Hi @citdevpros,
you are correct. if you do M-M relationship you need an intersect table. if you set up a many to many relationship in dataverse it creates this table automatically, but we dont get to see it (read here: Create many-to-many table relationships in Microsoft Dataverse overview - Power Apps | Microsoft Lea...)
Since we can reference it through galleries though (e.g. gallery 1 has the names and then gallery 2 you just set to gallery1.selected.Expertise ) i am wondering how to reference the intersect table to create a collection
My apologies, in my read of your question I made the error of making an incorrect assumption.
Edit 2024-02-29: see follow up reply. It is possible to address the relationship. However the part of this post showing that the relationship doesn't manifest in a collection when you collect the data source is still true.
I am happy to be proven wrong, but I don't believe that the "Expertise" property of the Name table data source is addressable in any way. Granted it can be used (per your example scenario) in the second gallery, but it appears that galleries have super powers to see the intersect table when they look at the data source.
To support this contention, when you ClearCollect a collection from the Name data source, either straight from the Name data source e.g.
ClearCollect(col_NameExpertise, Name)
or by using Name in the Items property of a gallery and then collecting AllItems of the gallery e.g.
ClearCollect(col_NameExpertise, gal_Names.AllItems)
and then you view the collection on the variables screen, the Expertise column is not shown. I would expect there to be a column of type table that you can ungroup, but clearly its absence suggests that the intersect table doesn't manifest as a data type we can work with.
I see no way to get this data into a collection other than to remove the relationship and create your own relationship table as a regular table.
Hi @barbossa_94 ,
I managed to prove myself wrong. PowerApps doesn't make this easy to figure out, even though the solution is simple.
This creates your "desired" outcome. but without the Category column.
ForAll(Name As T1, {Name: T1.Name, Expertise: Concat(Expertise, Expertise, " | ")})
I am not sure how this will work for you given that I am simply using the table and column names you provided in your example, and you use the words Name and Expertise for tables and fields. In my testing I had unique naming.
The challenge lies in referencing. PowerApps won't let me do the ForAll without the "As T1" alias, and Intellisense then offers me T1.Expertise in the Concat to reference the related table/relationship, but it will tell you that the column is "inaccessible in this context". Take off the alias and it works. What I am trying to say is THESE don't work
ForAll(Name As T1, {Name: T1.Name, Expertise: Concat(T1.Expertise, Expertise, " | ")}) //doesn't like T1.Expertise
ForAll(Name As T1, {Name: Name, Expertise: Concat(Expertise, Expertise, " | ")}) //No T1 prefix on Name column
ForAll(Name, {Name: Name, Expertise: Concat(Expertise, Expertise, " | ")}) //No "As T1", wont' recognise Expertise as a table in Concat
Hope you can make that work.
Ok i made some progress in here with @citdevpros 's help.
To achieve a collection which holds the name and then a string of the expertises you have to do the following:
First of all: In the canvas builder go to Settings --> Upcoming features --> and activate "Record scope one-to-many and many-to-many relationships"
Then create a collection as follows:
ClearCollect(col1,
ForAll(
NameTable as T1,
{Name: NameTable.Name,
Expertise: Concat(T1.ExpertiseTable,Expertise ," | "(
}
)
)
This results in a table with the names and a string with their expertises.
However the category is missing. @citdevpros With this knowledge gained, do you think we can realize a table like this?
Name | Expertise | Category |
Max | AutoCad | Software |
Max | PowerApps | Software |
Max | Planning | Processing |
Anna | AutoCaD | Software |
Anna | .... | .... |
... | .... | ... |
So caveat emptor on using experimental features. However turning on the "Record Scope" feature does do the trick. It is not straight forward though - despite this feature "allowing table operations", the fact remains (per my previous post) that the relationship doesn't manifest as a column we can reference, so we can't just simply ungroup it.
I am not saying this is the perfect answer, but it works.
This entire solution is based on Concat() being the only function I could get to actually reference the intersect table property of the NameTable datasource (there may be others).
Note to produce the data in the intersect table, you only need 3 steps. The 2 additional steps are only to group by category, per your original requirement. Here's the break down of the 5 steps, you could nest these but it doesn't make it easy to understand:
//Collect the related data as a nested delimited list
ClearCollect(col_Result_A, ForAll(NameTables As T1, {Name: T1.Name, xExpertise: Concat(T1.ExpertiseTables, Category & ";" & Expertise, "|")}));
Produces:
//Initiliase the next collection, we will use it as a Collect-only in the ForAll
ClearCollect(col_Result_B, Blank());
//Split the outer delimited values onto their own rows, collect in the inner collection col_Result_B, col_temp is just a dummy
ClearCollect(col_temp, ForAll(col_Result_A, ForAll(Split(xExpertise, "|"), Collect(col_Result_B, {Name:Name, xSplit: Value}))));
Produces (the Value column comes from initialising with Blank()):
//Split the category/expertise pairs into their own columns
ClearCollect(col_Result_C, ForAll(col_Result_B, {Name: Name, Category: First(Split(xSplit, ";")).Value, Software: Last(Split(xSplit, ";")).Value}));
Produces:
//Group expertise by name/category
ClearCollect(col_Result_D, GroupBy(col_Result_C, "Name", "Category", "Expertise"));
Produces:
//Create pipe delimited list of expertise, now by the groupings
ClearCollect(col_Result_Final, ForAll(col_Result_D, {Name: Name, Category: Category, Expertise: Concat(Expertise, Software, "|")}) );
Produces:
Use this collection as the Items property of a table, and you have your original requirement.
Hi @citdevpros ,
first of all, Thank you. This does work and leads to the result wanted. Also pretty straight forward once you understand it. Thanks for breaking it down. Is there a way to nest it smarter (more efficient) than simply sequencing all the functions with ";" ?
@barbossa_94 you're welcome, was a good learning for me too.
You can consolidate it, but only so far and it's pretty much impossible to make sense of, even less so if someone else wants to try to understand what you have done.
ClearCollect(col_Result_B, Blank());
ClearCollect(col_temp, ForAll(ForAll(NameTables As T1, {Name: T1.Name, xExpertise: Concat(T1.ExpertiseTables, Category & ";" & Expertise, "|")}), ForAll(Split(xExpertise, "|"), Collect(col_Result_B, {Name:Name, xSplit: Value}))));
ClearCollect(col_Result_Final, ForAll(GroupBy(ForAll(col_Result_B, {Name: Name, Category: First(Split(xSplit, ";")).Value, Software: Last(Split(xSplit, ";")).Value}), "Name", "Category", "Expertise"), {Name: Name, Category: Category, Expertise: Concat(Expertise, Software, "|")}) );
You can't nest the first line; you have to initialise that collection as empty and you can't nest that. You can't nest the second line into the third, since it's not col_temp that you want, it's col_Result_B that you populate inside the 3rd ForAll loop.
Good luck with it.
@citdevpros thanks again. This was certainly a life saver. I do believe that microsoft has to make this intersect table accessible somehow in the future. This is not sustainable at all to offer the many to many feature without doing so. For now I recommend everyone else to build an intersect table manually instead of using the microsoft virtual one.
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