Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

foreign key to be added to cds entity


I need some help related to creating foreignkey to one entity and how the data is displayed based on the foreignkey.
this to be achived by CDS.

Employee and Depatrment are two entities.
both contains DeptNo field is common, which is Primaykey on Department entity.
i want to display the data from both Emp and Dept entiies.

i check the lookup type in CDS is this the way to create foreign key to be added to cds entity.




Community Support Team
Community Support Team

Re: foreign key to be added to cds entity

Hi siva123,


Yes, you could create a Relationship from Employee entity to Department entity.
Then you could select the DeptNo from the Department entity and also show it on Employee entity.


Please check this documentation for more details:


Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

Re: foreign key to be added to cds entity


I have two questions concerning LookUps in the CDS/PowerApps.

I have 2 Entities in my CDS: Machine and Incident. They are connected via a "Relation" in the CDS.
I now have a problem with querying it:

In my App i have a gallery displaying all my machines, besides the machine-gallery, there is another gallery displaying the incidents. All i want is that the incident-gallery shows only the incidents that belong to the machine selected in the machine gallery.
My approach was to set the filter to the Incident Gallery like follows:
Filter(Incidents; Machine_.PrimaryId = MachineGallery.Selected.PrimaryId)

This statement does work like intended, i get this "blue waves" however that i can only execute the query locally.

1) Is there another way to realize a query like this? If yes, how?
2) Wouldn't it be easier if the "Lookup-Field" inside the (in my case) Incidents Entity just contained the PrimaryId of the Machine in either string or int format (much like a foreign key in SQL works) instead of referencing whole machine-object?
The Filter "Filter(Incidents; pmMachine = MachineGallery.Selected.PrimaryId)" - which was my first intention - didn't work.

It's very unfortunate in my opinion that the CDS and PowerApps together are not capable of delivering basic querying functionalities and i really do hope that this soon gets better.

Thank you in advance

Microsoft Employee

Re: foreign key to be added to cds entity

I do have the same requirement. Can someone please help?

Helpful resources


PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.


Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.


Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Power Platform World Tour

Coming to a city near you


PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Join PowerApps User Group!!

Connect, share, and learn with your peers year-round


Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 363 members 4,183 guests
Please welcome our newest community members: