Hello,
The project I am working on has a few One To Many relationships. I have successfully set up one 1:N relationship between two tables. When I view data of the parent table in CDS, I see the records of the child table. So the relationship is right.
But I do not see a column in the parent table that points to the child table. I need to create a calculated column on the parent table and the value of the calculated column will be determined by its child records. For this reason, I think I need to be able to access the child records of a given parent record. But the calculated/rollup interface does not show me that option. But I do get to see the lookup tables that the lookup columns of the parent table point to.
Could someone please tell me:
1) What is the difference between a lookup table and a relationship? When should I use one vs the other? The concepts seem different from the old relational database design concepts.
2) If setting up a 1:N relationship is the right thing to do, how do I populate a calculated column on the parent table based on the values of the child table?
Thank you for your help.
John
In Dataverse (formerly Common Data Service or CDS) the way to get an aggregate value of a field across multiple child entity records associated with a parent entity, and get that aggregated result to show up on what you call a "calculated field" on the parent entity, would be to, instead of using a "calculated field", to use a Rollup Field on the parent entity.
More information:
https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/define-rollup-fields
@JohnYu500 wrote:
Could someone please tell me:
1) What is the difference between a lookup table and a relationship? When should I use one vs the other?
We are unfamiliar with the terminology of a "lookup table" in Dataverse.
If you meant a "lookup column" (ref) versus a "relationship", here is explanation:
The "relationship" you are referring to, the main kind which is 1:N , let's suppose that one Account record can have many Contact records. The subgrid would be on the Account record, and can list 0, 1, or more than 1 Contact records associated with it.
On the other side of the perspective, the same relationship exists as Many to One, or N:1 between Contacts and Accounts - which is the same relationship actually, just seen from the other end.
Only this time, any one distinct Contact record optionally has a specific reference to exactly one Account record, usually visually represented through a lookup column (previously called a lookup field) on the Contact. Another distinct Contact record, also can have the reference in the lookup column pointing to that same specific Account record as well. This would cause there to be those two exact contact records to be shown in the subgrid on the Account record side, and on each of the two distinct Contact records, the lookup field set to be pointing to the same Account record. So many Contacts can have one Account or N:1 from Contact to Account.
The N side of the relationship usually has the lookup field on it, or what is called a lookup column. (note that field has recently been renamed to column, as part of the round of name changes related to CDS rename to Dataverse)
@JohnYu500 wrote:
The concepts seem different from the old relational database design concepts.
No this part is the same actually.
In our opinion it is just being represented in a little bit easier way actually. When you see a lookup column (formerly lookup field) on a record form, you can already tell that this Table (formerly called an Entity) has to have an N:1 there in some way. When you see a subgrid on a record form, you can already tell it has to have a 1:N in there for that Table (formerly called an Entity).
So that is why Dataverse is quite useful and powerful in this respect as it matches very well with database design concepts.
Let us know which part you think is very different from relational database design concepts.
Finally, here are some visual examples to help more with the above:
Account View
Contact View
Account Records:
Account 1 Record Form Subgrid listing both of the 1:N associated Contact Records
Account 2 Record Form Subgrid listing the associated 1:N associated Contact Records(there happens to just be one here, but there can be zero associated records, one associated record, or more than one associated record)
Contact Records:
Contact Number One Record Form with lookup column (previously called a lookup field) N:1 pointing to Account 2:
Contact Number Two Record Form with lookup column (previously called a lookup field) N:1 pointing to Account 1:
Contact Number Three Record Form with lookup column (previously called a lookup field) N:1 pointing to Account 1:
In all three of the above screenshots of each Contact record, the lookup column (previously called a lookup field) points to exactly one Contact record. However, notice that more than one of these records can possibly point to the same record - that is why it is N:1 and not 1:1.
In Dataverse, a true 1:1 relationship between two tables cannot be modeled natively in the specific way you might have in mind (without some specific potential workarounds), this might be the only real difference. A one to one relationship in Dataverse is usually natively built as just another regular column (formerly called a field) on the same Table.
Moreover, note it is also possible for the lookup column (N:1) on a Contact record to be simply left blank and not point to any single Account record at all (unless it is set as a required field) - the relationship and lookup by themselves do not necessary imply that the record must be associated, only that it can be associated.
We also use the word record very often to deliver the following point.
The definition of a Table (formerly called an Entity) is very different from the actual records contained in that table. The 1:N relationship is best understood keeping the records of the Tables in mind. The records are the actual things that end up having the relationship with other records - the Tables are just the ones that determine through definitions of the relationships, that the relationships are possible between the records of those Tables in those specific ways. The lookup column is usually the hint of the N:1 relationship, and subgrid the sign of the 1:N relationship. Note that the column and the subgrid need not be actually present on the form for the relationship to exist, but if they are present, they are how you can easily tell the relationships and in what direction they are.
In other words, placing a subgrid on a form to show one, or more than one associated record from another table,
usually requires the 1:N relationship to be defined first between the two tables,
and placing a lookup column on a form to reference one associated record from another table,
usually requires the N:1 relationship to be defined first between the two tables.
Hope this helps.
Thank you for your prompt reply.
With the 1:N relationship where both the parent table and the child table have a currency column, I am able to populate the currency column on the parent table using rollup.
I have another column, which of data and time type, on the parent table and I want to auto-populate it with the value of one of the datetime column of the child table based on some condition. When I tried to do this, I do not even see the child table listed in the Entity list.
I am not sure if I have made myself clear.
Thank you again.
John
Canvas Apps can be embedded in Model Driven App Forms with context , so you could embed a Canvas App in a Model Driven App and implement the functionality in the Canvas App.
It is also possible to use instead a
web resource,
Power Automate
or
(because Business Rules may or may not be enough to do this specific scenario)
Other than this, we are unsure if it possible to do this only from a calculated field or rollup field in this case.
We would be curious how to do this only with the Calculated Field or Rollup Field. It may be possible but we are not sure in your specific scenario how it would be done. For that we would welcome another user in this forum to suggest a solution using only the Calculated Field or Rollup Field - or to elaborate more on another possible approach.
Thank you so much for the detailed explanation.
Regarding the lookup column: you are right. I did not make myself clear. I did mean to say the lookup column of a table. I believe the table a lookup column points to (or references) is the lookup table.
I now understand that this lookup concept is actually the same as it is in relational databases.
I also understand what the 1:N or N:1 relationship means. But somehow I still cannot get what I am trying to do.
Here is exactly what I am trying to do.
I have a contract table and an options table. A one-to-many relationship is set up between the contract and the options table, which means a contract has one or more options. Pretty straight forward.
On the contract table, I have a column of data and time type called RenewDate. And on the options table, there are some columns: StartDate, EndDate, isActive, fundingAmount, etc.
Now what I need is automatically populate the RenewDate on the parent table with the EndDate of the option that is Active.
When I was trying to use the calculate inteface to implement it, the interface does not even give the option to get to the options table. But the interface does give access to the lookup columns. This is where I need help.
It seems difficult to explain. Hope I made myself clear.
Greatly appreciate your assistance.
John
I do not necessarily have to use the calculated feature to achieve. This happens to be the only thing I know/learned for PowerApps. But I do want to achieve this from the Dataverse because I'd like to centralize the logic.
Thanks.
John
@JohnYu500 wrote:
On the contract table, I have a column of data and time type called RenewDate. And on the options table, there are some columns: StartDate, EndDate, isActive, fundingAmount, etc.
Now what I need is automatically populate the RenewDate on the parent table with the EndDate of the option that is Active.
One thing we notice here, is in this way you set it up, more than one contract could have the isActive state set upon it. Presuming you do not want this, and presuming only one option must be active at a time - then using a web resource, Canvas App, or Power Automate could be insufficient as it would not enforce the integrity in the server side in a solid way, because for example suppose an embedded Canvas App has it all there. However the integrity rules can be violated from say a Model Driven App form, that is existing elsewhere, and then cause more than one Active option to occur, and violate the integrity. And also, we are unsure that the simpler alternative one should always check first, the Business Rules can actually do something of this complexity - if they could though, those are enforced when the scope is set on the whole Table, so those would work if it were possible - but we are unsure Business Rules can do it for this scenario.
So it is likely a custom Plugin (this is written in C#) is needed to be developed and registered against the appropriate message on that Table, so that when the record is updated from the N side to set isActive to true, first it must fetch the associated record (the one side) by the Lookup Field - then it must enumerate all the N side of the records to see if any other associated record form the N side is set to Active. If one already is, it must throw the error message and then block the change attempt in the current record - then it will work.
The same Plugin can then also do as follows for rest of your functionality: If the condition above is false, then it will also just lookup the 1 side from that record N side and just go ahead and directly set that date you want from the N side, over on that field from the one side.
The same Plugin also can check - if the value is being changed from Yes to No on isActive, it can then clear the above one side's field to the blank value.
Now to implement this with the sample C# code, we would need to take quite some time to do this, it is very advanced to do this. If we happen to have some time to do this, we might reply with a specific sample and details of it so you can check it.
Which is why if someone else on this forum have the more creative idea than this, it is most welcome and we would also be interested to know of it - in our opinion though, we are unsure if any of the possible creative ideas, do not have a tradeoff, such as that there is a way to set two isActive states outside of the app. The creative idea that other person may have, may have to suggest you to rethink the way you set up the data in the first place to avoid this pitfall.
If later we happen to have such idea, we might check back and let you know in a reply as well.
If you do not care if two isActive states are set, there may be more options such as the web resource - however, the moment we say "if you do not care if two isActive states are set" it already does not feel good, the only way we could feel comfortable with it with the way the data is set up is with custom Plugin so it is a very solid solution is what we can say for now.
You are right. There could be more than one option record that is IsActive (true).
I do care about data integrity and I planned to use Business Rules to enforce that although I have yet to figure out how to do this.
I seem to read from your message that the way I set up the relationship between these two tables is not appropriate. If this is the case, how would you set it up? I want to get my data model right. I am talking about U.S. federal contracts that usually have some option periods - which is a typical one-to-many relationship. So it is natural to create a 1:N relationship between contract and options.
Hope I do not have to go through the custom C# code route.
John
@JohnYu500 wrote:
You are right. There could be more than one option record that is IsActive (true).
I do care about data integrity and I planned to use Business Rules to enforce that although I have yet to figure out how to do this.
I seem to read from your message that the way I set up the relationship between these two tables is not appropriate. If this is the case, how would you set it up? I want to get my data model right. I am talking about U.S. federal contracts that usually have some option periods - which is a typical one-to-many relationship. So it is natural to create a 1:N relationship between contract and options.
The thing is we think you set this all up correctly in our opinion. We are unsure right now of another way to set it up to be honest with you. We were just saying we suspect there might be some other, different way to set it up (that could require some time to think of it), that would result in suddenly not having to go to the custom C# code route. However, right now we are not so sure what that way is.
For this reason - if we think of either a) the other way to avoid the custom C# route or b) to just do it that C# way and provide it to you (but this can take time, we'd have to check if we have the time to do this - you are also welcome to try it of course) - we would let you know if we have either of these two cases.
Right now we don't have either yet - so in the meantime we welcome the response from another perspective if someone else here on this forum would like to volunteer to check on this for you.
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