(QGIS 3.4) The image below will help explain my goal:

I'm working out how to coalesce the attributes of the field "ID" if the field "X, Y" is a duplicate.

I have highlighted some duplicate coordinates in red. My expression will create a new text field and chain all attributes in the "ID" field, delimited by a pipe (`|`). 

For example, where I have labelled features with blue text 1,2,3, the new field will write 

`Special Protection Areas | Scheudled Monuments | SSSI | AONB | Special Areas of Conservtion | Scheduled monuments | Scheduled Monuments | SSSI | AONB`

I will omit duplicate values later in excel.

[![enter image description here](https://i.stack.imgur.com/W6JnC.png)](https://i.stack.imgur.com/W6JnC.png)

Here's what I have so far...`if( "X, Y" = "X, Y" , coalesce( "ID" ),' ')` but this just duplicates the "ID" field without any coalescing.
['https://gis.stackexchange.com/questions/330473', 'https://gis.stackexchange.com', 'https://gis.stackexchange.com/users/93834/']
With credit to Vince, the correct expression to use in this case was:

```
concatenate( to_string( "ID" ),group_by:="X, Y",  concatenator:='|')

```
In QGIS I can suggest using a [**"Virtual Layer"**](https://docs.qgis.org/3.10/en/docs/user_manual/managing_data_source/create_layers.html#creating-virtual-layers) through `Layer > Add Layer > Add/Edit Virtual Layer...`

Let's assume there is a point layer with it's corresponding attribute table, see image below.

[![input](https://i.stack.imgur.com/L1oUw.png)](https://i.stack.imgur.com/L1oUw.png)

With the following query, it is possible to achieve the result.

```sql
SELECT "X, Y", GROUP_CONCAT(info, ' | ') AS info_concat
FROM "points"
GROUP BY "X, Y"

```

The output Virtual Layer will look like as following

[![result](https://i.stack.imgur.com/DgsTE.png)](https://i.stack.imgur.com/DgsTE.png)

*Note:* Geometry is not included in the final output, otherwise extend the query with `geometry` parameter and to check how many points were grouped insert `COUNT()`, i.e.

```sql
SELECT "X, Y", GROUP_CONCAT(info, ' | ') AS info_concat, geometry, COUNT("X, Y")  AS pperloc
FROM "points"
GROUP BY "X, Y"

```

---

**References:**

* [SQLite GROUP\_CONCAT](https://www.sqlitetutorial.net/sqlite-group_concat/)
* [W3Schools | SQL COUNT(), AVG() and SUM() Functions](https://www.w3schools.com/sql/sql_count_avg_sum.asp)