Forum Discussion

P_D_G's avatar
P_D_G
Resolver III
5 years ago
Solved

Improve data model - multiple relationship between tables

Hi all,

 

I'd like to recreate my data model in a more efficient way.

 

I have a Table1 with transaction data, this data is also geocoded an contains only unique rows. However, I also have Table2 which contains the nearby locations related to Table1.

Table1

TransactionYearLocationLatLongValue_1Value_2
2019Location_119.0333629.611621193
2019Location_2-14.25842.9575119299
2019Location_3-66.9449-38.478711815
2019Location_4-59.3971-60.587311053
2019Location_5-60.0055-19.8784082
2019Location_6-35.9316-118.366108155
2019Location_766.3981-52.6308441
2019Location_839.34878-112.259128170
2019Location_957.37424-151.71750197
2019Location_1017.8441-60.5622144161

 

Table2

LocationRelated_Location
Location_1Location_2
Location_1Location_3
Location_1Location_4
Location_10Location_1
Location_10Location_3
Location_10Location_6
Location_2Location_1
Location_2Location_10
Location_2Location_5
Location_3Location_4
Location_3Location_7
Location_3Location_8

 

Every time I select one record from the table on the left I'd like to display the selected location (middle map) and all the nearby locations (right hand map).

 

Displying the selected location on the middle map is easy, however I need the location of the nearby locations too. Currently I'm using lookupvalue (I could use merge in Power Query too) to get the lat-long value pairs from the first table, but I think that this is creating a lot of redundancy as I already have this info in Table1. All in all I believe that this may not be the best way, but I couldn't come up with a better way to create this when playing around with different "fact" tables or relationships.

 

Any idea how to improve the model?

Example file here.

 

Thanks,

PDG

  • P_D_G , a simple but tricky solution to your issue is to append a "self-referenced" table to Closest_Locations table in PQ,

    In the meantime, retrieve lat/long info from Main_Table by simply merging them in PQ; then when you choose one location from Main_Table, the chosen location, along with all related locations show on the map simultaneously.

     

     

2 Replies

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion

    P_D_G , a simple but tricky solution to your issue is to append a "self-referenced" table to Closest_Locations table in PQ,

    In the meantime, retrieve lat/long info from Main_Table by simply merging them in PQ; then when you choose one location from Main_Table, the chosen location, along with all related locations show on the map simultaneously.

     

     

    • P_D_G's avatar
      P_D_G
      Resolver III

      I knew I was overcomplicated things... Thanks for the help!