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
gavinashton
Regular Visitor

DAX count for a relationship two tables out

I'm jumping straight into my first PowerBI report with something relevant to me! Here's my data:

 

People table
ID            LocationID
Joe          123
Sally        456
Jackie      123

 

Location table
ID         Address                     CityID
123       1 Privett Drive           abc
456       2 Mulholland Ave      xyz

 

City table
ID          Name
abc        London
xyz        Tokyo

 

What I'd like to do is start with a global heat map of People by City
Then if you zoom into the city that heatmap changes to Locations within that city

 

So at the core of this is going to be something where we have a count of People associated (via Locations) to City
And then users associated to Locations:

 

I think this is going to look something like a mapping between People LocationID and Location ID, and then between Location City ID and City ID, following by a little DAX:

 

Users at Location = (sum(Location(ID);RELATEDTABLE(People)) <- for this I have a mapping between those two attributes.
Users at City = (....  and this is where I get stuck! How do I do the double-hop?

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @gavinashton,

 

According to your description, it seems that you want to count people in each city, right?

 

In your scenario, you can build relationship among those three tables. Then create a measure in City table like this:

 

CountPeopleInCity = COUNTROWS(People)

 

z3.PNGz4.PNG

 

Best Regards,
Qiuyun Yu

 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-qiuyu-msft
Community Support
Community Support

Hi @gavinashton,

 

According to your description, it seems that you want to count people in each city, right?

 

In your scenario, you can build relationship among those three tables. Then create a measure in City table like this:

 

CountPeopleInCity = COUNTROWS(People)

 

z3.PNGz4.PNG

 

Best Regards,
Qiuyun Yu

 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, I need to count cities and locations (zooming into the map you get cities at global scale then locations at a deeper level). But this looks like a good option, I'll try it out 🙂

Hi @gavinashton,

 

Is our suggestion helpful for you? If that is a case, would you please mark a helpful reply as an answer to close the thread?

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
CahabaData
Memorable Member
Memorable Member

Make join lines between the tables.  Then the Related function should offer those tables/fields as part of Intellisense.

www.CahabaData.com

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.