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

Using 2 data sources for showing map data

Hello,

i have an app based 2 data sources

  1. Users sharepoint list with Person Name, email and City names
  2. Locations sharepoint list with city names and their Lat and Long

When the user open the app he can select 2 screens

  1. User screen where he is recognized by the app with a lookup on the email LookUp(UserData, User().Email=User.Email.
    In this screen he can use a dropdown loaded with all city names from Location sharepointList. When he select one value, the selected value for the city name will be saved in the Users sharepointList in the City names column
  2. All Users screen based on a search text input, a map component and a gallery. Inside the gallery the user can see all the users from the Users sharepointList and in the map he should see pins for each user in his own location. 

The problem lays in the All Users screen.

i can easily show all users inside the gallery, using the following code in the Items element of the gallery

Search(
    AddColumns(
        UsersSPList,
        "UserName",
        User.DisplayName,
        "LocationName",
        'Location: City',
        "Location2",
        'Location: State'
    ),
    Searchbar.text,
    "UserName",
    "LocationName",
    "Location2"
)

 

but how can i show the same data on the map considering that it should match user and location based on the city?
For instance it should take the first user, check the City value in the Users SharepointList, lookup for that City in the Locations SharepointList and retrieve Lat and Long from there...
how can i accomplish this? what should i write inside the map Items value? how can i load two data lists inside the same search function?


I have to use this messy approach because the address component doesn't let me search for cities instead of addresses, and for privacy policies i can just ask the user for his city. Had to make this huge list with cities and their locations... 

Thank you so much



1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Antonioclk ,

 

You could try:

With(
 {TheTable:Search(
    AddColumns(
        UsersSPList,
        "UserName",
        User.DisplayName,
        "LocationName",
        'Location: City',
        "Location2",
        'Location: State'
    ),
    Searchbar.text,
    "UserName",
    "LocationName",
    "Location2"
 )},
 ForAll(
   TheTable,
   Patch(
     ThisRecord,
     {
       Lat:LookUp(Locations,CityName=ThisRecord.LocationName).Lat,
       Long:LookUp(Locations,CityName=ThisRecord.LocationName).Long
     }
    )
  )
)

 

Best Regards,

Bof

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @Antonioclk ,

 

You could try:

With(
 {TheTable:Search(
    AddColumns(
        UsersSPList,
        "UserName",
        User.DisplayName,
        "LocationName",
        'Location: City',
        "Location2",
        'Location: State'
    ),
    Searchbar.text,
    "UserName",
    "LocationName",
    "Location2"
 )},
 ForAll(
   TheTable,
   Patch(
     ThisRecord,
     {
       Lat:LookUp(Locations,CityName=ThisRecord.LocationName).Lat,
       Long:LookUp(Locations,CityName=ThisRecord.LocationName).Long
     }
    )
  )
)

 

Best Regards,

Bof

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (5,225)