Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
P_D_G
Resolver III
Resolver III

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).

P_D_G_0-1613579429986.png

 

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

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
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,

Screenshot 2021-02-17 225010.png

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.

Screenshot 2021-02-17 225735.png

 

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
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,

Screenshot 2021-02-17 225010.png

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.

Screenshot 2021-02-17 225735.png

 

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.