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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Cbutler
Helper III
Helper III

Count IDs by minimum value for the category - must be dynamic!

Riddle me this!

I am trying to count the number of people by their closest building - so distinct count of people is 2,061, distinct count of buildings is 7. I have mapped the distance of every person to each building by KM and Miles (file contains 14,427 rows). I need to be able to see the number of people by their closest building - but this needs to be a dynamic measure as I want to be able to unselect a building and have it recalculate all people to their next nearest building. 

So I want to be able to count the total number of people by their closest building in a bar chart. 

Eg Person 1 closest building is A, then A is removed from the filter, so their next closest is E and they will be counted with that building, then if E is removed theyll go to D etc etc. 

Any ideas of how to do this in a measure? @Greg_Deckler can you help? 
@GuyInACube any ideas for this problem? 


Link to PBIX download here 
Number of people per building.pbix

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

4 REPLIES 4
lbendlin
Super User
Super User

lbendlin_0-1686349861689.png

see attached

Hello Ibendlin, thanks so much for your help, I am wondering if you can assist again please? 

I have added in a new column for travel time in to the table,
(Less than 30 mins, 30mins -1 hour, 1-1.5 hours, 1.5-2 hours, more than 2 hours). 

this is for each row, each person distince to building and travel time. 

How can I adjust the code so that I can dynamically show the number of persons by their travel time? 
They still need to have been sorted by their closest building.... 🤔

Picture1.png


Thanks 🤞

You can adjust the DAX to swap out the distance for the time - after you put the time column into a usable (countable) format. Right now it is an inconsistent, unusable mess.

Thank you! This is exactly what I needed! 🎉

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.