How can I make my app to display the location name and address only once if there are multiple records for the same location? ( like in the attached image )
Create a relation from the location name to itself without match multiple. Lookup the row IDs. You’ll notice that only the first occurrence of duplicates has a matching row ID and looked up row ID. Create a query column with a filter: row ID is this row’s looked up row ID.
This should return the table with unique values only along the location name.
I have to do it in the Data section? I can’t do in Layout section?
In the Data Editor.
The basic idea to “remove duplicates from a collection” is the filter the collection to only show the first occurrence of duplicates. The filtering can either happen in the layout editor (method 1) or in the data editor (method 2).
Method 1: Filter with checkbox
In the Data Editor:
- Create a
Row ID
column - Create a
Relation
column from Name to Name (not match multiple) - Look up through the relation the row ID. This will give you the row ID of the first occurrence of your duplicates.
- Create an
If-Then-Else
column : if row ID is first occurrence row ID then true else null (empty). Now everywhere where you have a checked checkbox, you know that that row if the first occurrence of any duplicates you might have.
In the Layout Editor
- Create your collection
- In options on the right hand side, filter the collection : first occurrence checkbox is checked
Method 2: Unique table with Query column
In the Data Editor:
- Instead of an if-then-else column (method 1 above), create a
Query
column and filter: Row ID is First Occurrence Row ID (it’s the same idea as above). You are querying the table and asking the query to return the rows of the first occurrence of duplicates. - Here, only the first row of the Query column is useful.
In the Layout Editor:
- Create your collection
- As the source of the collection, select the
Query
column.
I’m not too sure which method I prefer. The method with query feels slightly cleaner, though it might be confusing that only the first row of that column is being used (it confuses me!).
K I will study your solutions. Thanks for your help.
Why do you have duplicated locations in the first place?
I guess you would want a mechanism to prevent that if your app is allowing users to submit?
yes users enter information into a form, including the location name and address. do you have a solution for the problem?