cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vsolanon Helper III
Helper III

Create dependency between two date pickers within two different SharePoint lists

Hi Experts!

I am creating two SharePoint lists that are connected to a PowerApps application. The SP List1 "TripsList" shows all the trips a person can choose, and the SP List2 "Destinations", shows all the destination a person might be within a trip.

The relationship is one to many since one person might be in more than one destination during the same trip. For this, I created a column named "Identifier" which connects both lists. In the SP List1 the "Identifier" will be used only once, however, in the SP List2, it might be used more than once

 

The List2 has two additional date column; "FirstDate" and "EndDate". The end-user must select the start and end date in each destinations in the SP List2.

The List1 has a date column named "FlagFirstDate".

 

I would like to create a rule to gather the closer date of each trip in the SPList1 ( to be store in the column "FlagFirstDate".),  based on all  dates the end-user select in the field "FistDate" within the SPList2.

For example, if I have 3 destinations in SP List2 with the same identifier 1111 , then the "FlagFirstDate" on the SP List1 for the identifier 1111 must be filled with 02/10/2020, since this is the closer date (the smaller)

          Destination1-->  FirstDate:  02/10/2020       EndDate:02/28/2020

          Destination2-->  FirstDate:    03/02/2020     EndDate: 03/15/2020

         Destination3-->   FirstDate:    03/18/2020     EndDate: 03/30/2020

 

Thank you in advance 🙂

 

1 REPLY 1
MarvinBangert Resolver III
Resolver III

Re: Create dependency between two date pickers within two different SharePoint lists

Hey @vsolanon 

 

Hope I got you correctly:

There are two SharePoint lists "TripsList" and "Destinations", both are connected by an identifier-field with a number e.g. "1111". A user can select a trip from the "TripsList" and select different destinations for this trip.

First questions: can only one user book a trip, so when a user already booked a trip, it is not visible to other users anymore?

 

To solve your problem, you can use the First()-, Sort()- and Filter()-Function. Your code should look like:

First(Sort(Filter(Destinations,Identifier.Value = "1111"),FirstDate,Ascending)).StartDate

 Then you should receive the first date from you "Destinations"-list for the trip with the identifier "1111" (you can test it within a label first). To update this item, you could use the patch()-Function, to update the value within the "TripsList".

Have a look at the docs for further information about how to use the patch()-Function: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

 

Hope this will help you 🙂

 

Regards

Marvin

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (6,735)