Would like a way to group a list by city

I have a list view on a page in my app.

At the moment this works fine because there is not much data but I would like to figure out a way to make it so that cities don’t repeat but they group. So you would click on a city and then the city button opens a list of the sites available in that city and you click on the individual sites to see their info.

Background info that might be helpful. I am collecting information about when repeating events happen had specific locations. I have a form that users can fill out that will summit the data then all that will be needed is for someone to occasionally check it and tidy it up for it to spit into the app correctly.

You will need to use the relation column to link locations to cities. I have made a sample app that you can clone: https://citieslocations.glideapp.io

Then once you have done this, add an inline list on each city’s details screen and choose the ‘Location Relation’

This would all be done on the ‘Cities’ tab - but your form would populate to the ‘Locations’ (or in your case ‘Sites’) sheet.

1 Like

Thank you! That is what I need but now I have a follow up question. Is there a way to remove duplicates? I have set up a formula to pull the cities from the user submitted form. But just pulling it directly will mean that there will be duplicates.

Is there a formula I can add or would that be a script that would need to be written (still working on learning scripts!).

Thank you

Look into using UNIQUE or using queries with Group By.

Jeff Thank you!
I got it to work with this: =Unique(QUERY(‘Suggested Edits’!A4:A))

I am learning so much, which I am using for ideas for other apps! Thank you Jeff and Jack for your help with this one!

1 Like

So I thought I had it but, I don’t.
I can get the cities to show up as a list, I have created the relationship on the data page which has grouped the cities how I want, I have gotten the map view to work, but it is only showing one entry on the map.

Any thoughts were I might have gone wrong. I have tried a side by side comparison of the app example but I can’t seem to find it.

Do you have any screenshots? Where do you have the map? Is it after you click on a city? I’m assuming you have a unique list of cities. You then click on a city to view it’s details. In there you have an inline list of sites for the city that you are viewing as a map. When you set up the relation, did yo click on the Multiple checkbox?

I followed the template that Jack sent. So you have a list of cities, You click on them and you get a map that shows the different locations in that city. On his version both locations in 1 city appear. On mine I get one pin and only one location.

I did click Multiples allowed and I see that it identifies both locations on the data/relationships column.

I do have an inline list for the cities.

I think the pins are there. Your last screenshot looks like 2 pins almost on top of each other. I’m not sure why it’s zoomed out so far. What happens when you zoom in on the map? What do the addresses look like?

It was not showing two pins and the pin wasn’t even correct for either address. I am just going to put it in list view and call it a day at this point. Thank you for your help.

My only concern is that the address column isn’t a complete address. Hard to say without seeing what it looks like. You could always obtain the coordinates for the address and use that instead.