cancel
Showing results for
Did you mean:
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
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

Accepted Solutions
Moderator

## Re: DAX count for a relationship two tables out

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)

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.
4 REPLIES 4
Solution Sage

## Re: DAX count for a relationship two tables out

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

Moderator

## Re: DAX count for a relationship two tables out

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)

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

## Re: DAX count for a relationship two tables out

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 🙂
Moderator

## Re: DAX count for a relationship two tables out

Hi @gavinashton,

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.

Announcements

#### New Ranks Launched March 24th!

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

#### ‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

#### Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

#### Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

#### Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors