# How to select data for a given user when using export CSV button

**URL:** <https://community.glideapps.com/t/how-to-select-data-for-a-given-user-when-using-export-csv-button/81552>\
**Category:** Ask for Help\
**Created:** [April 25, 2025, 10:28pm UTC](https://community.glideapps.com/t/how-to-select-data-for-a-given-user-when-using-export-csv-button/81552 "2025-04-25T22:28:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tristan\_Bonnevie](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tristan_bonnevie/32/86907_2.png) [@Tristan\_Bonnevie](https://community.glideapps.com/u/Tristan_Bonnevie)\
**Post date:** [April 25, 2025, 10:28pm UTC](https://community.glideapps.com/t/how-to-select-data-for-a-given-user-when-using-export-csv-button/81552/1 "2025-04-25T22:28:44Z")

</div>

Hi,

I’am reaching out to inquire about the possibility to select data when exporting data table using a button with export CSV ?

In this screen below, i would like to export data only base on “type utilisateur”.  
Thank you for your support,  
Kind regards

 ![ScreenTEST](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/9/b9c1bb354ab6f801e199d5c72698c3e1e253a2ba.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [April 25, 2025, 10:42pm UTC](https://community.glideapps.com/t/how-to-select-data-for-a-given-user-when-using-export-csv-button/81552/2 "2025-04-25T22:42:11Z")

</div>

I think you can create a query or relation with only the data you want and use that as the source for your CSV.

---

<div class="post-metadata">

**Author:** ![Tristan\_Bonnevie](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tristan_bonnevie/32/86907_2.png) [@Tristan\_Bonnevie](https://community.glideapps.com/u/Tristan_Bonnevie)\
**Post date:** [April 26, 2025, 7:08am UTC](https://community.glideapps.com/t/how-to-select-data-for-a-given-user-when-using-export-csv-button/81552/3 "2025-04-26T07:08:45Z")

</div>

I’am sorry, i dont see how to proceed.

To further describe the context, users are able to attribute or remove medical device to participants in research context. I have a data table to track audit trail (each attribution or removal, with date). What i want is that a given user can extract the audit trail data, but limited to the research he participates in (“Type Utilisateur”), whichever was the user that attributed/removed devices, as long as it belongs to the same research team.

 ![ScreenTest2](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/e/ee6ead8ac82e2ae998e12fc8cb34cbd697e25074.png)

In the app, using filter, i can make user to see only audit trial for the study they participate, but when i create the button to extract csv, the whole data is extracted. If query or relation is adapted, please, could you further describe how you would proceed ?

Thank you very much for your kind support.  
Regards,  
Tristan

---

<div class="post-metadata">

**Author:** ![Nicolas\_Joseph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nicolas_joseph/32/76105_2.png) [@Nicolas\_Joseph](https://community.glideapps.com/u/Nicolas_Joseph)\
**Post date:** [April 26, 2025, 2:31pm UTC](https://community.glideapps.com/t/how-to-select-data-for-a-given-user-when-using-export-csv-button/81552/4 "2025-04-26T14:31:58Z")

</div>

Hi @Tristan_Bonnevie

If I have well understood your use case, in your example:

- `Bonnevie Tristan` should get all the records because you are belonging to “Etude faisabilité clinique” and also to “HYBREATH”
- `Test utilisateur` should only retrieve rows 5 to 8 because he/she is only part of “Etude faisabilité clinique”

As Jeff suggested, a Query seems to be the best solution. To achieve that, we first need to list for each User what “Type utilisateur” he/she is part of.  
To showcase this, I created a sample “Audit trail\_test” table like this:

 ![chrome_RecJT6DSOi](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/c/5c150496069da77a7172cc88fcc5756148e9607a.png)

Now, let’s go for the hard work 😛 . In the **Users table** :

1. Create a Relation column (mine is named **All Type utilisateur (relation)**).  
You want to find all records of **Audit trail\_test \> Utilisateurs** that match the **User \> Name**. Be sure to select “Match multiple” to find… multiple records. And don’t worry about the data displayed, it’s the value of the first column of the table. It just the way Glide tells you “I have found theses results!”.  

2. Create a Joined List column (**All Type utilisateur (joined list)**). You join texts in **All Type utilisateur (relation) \> Type utilisateur** to get all the values of Type utilisateur available for this specific user row.  

3. Create a Query column ( **Records for Type utilisateur** ). This way, you can bring all the records where Type utilisateur is in the list of this user Type utilisateur. Same here, be sure the click on “Match multiple”.  

In the layout, you now have two options:

1. Keep using your **Audit trail\_test table** and filter it out as you mentionned
2. Use this **Query** as the source of your Collection (Data Grid in your screenshot). It’s probably more secure and efficient because if you change your Query to add more filters in the future, you’ll only have to apply the modification in the Query definition and it will be reflected in the view (but, you also might want to display something different of course)  
 ![chrome_3TSHOwyR1Y](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/6/e6bc17bced67e253fa7c5b2faffbd239fc964976.png)

And for your Export button, it’s the same logic:

1. Add the button to the layout
2. Select Generate CSV file
3. Change Source data to **User Profile \> Records for Type utilisateur**  
 ![chrome_FjQ30X7D87](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/e/ee0d29f54371acf1c96e9669c897eb6d1bad4e0c.png)

At this point, if the User change, data also change based on the query. If I’m now connected:

- as Tristan, I have all rows because I’m in EFC and HYBREATH  
 ![chrome_7dECALGf2s](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/6/a640c7d74e6f56d44f03bc900b8cb383a8a11dd9.png)
- as Jeff, I have all HYBREATH rows because I have at least one row HYBREATH. I don’t see EFC because I have no row like that in the Audit trait\_test table.  
 ![chrome_M0DTph9vq5](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/1/01d5a827a2e848225a6b0547776ee913bb9369a9.png)

**BONUS:** by clicking on “Select columns”, you’ll be able to select only the relevant columns you want in the export and also rename them (pretty cool feature I wanted to mention 😃 )

 ![chrome_XqdWiSzVy9](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/2/825c37b13d5baea38a718c618d665dcf25f8ebf2.png)

**In a nutshell:** the Query column lets you retrieve data from another table and apply filters. This query can then be used as the source of a component or to aggregate data (such as counting the number of rows) 🙂

Hope it helps!

---

<div class="post-metadata">

**Author:** ![Tristan\_Bonnevie](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tristan_bonnevie/32/86907_2.png) [@Tristan\_Bonnevie](https://community.glideapps.com/u/Tristan_Bonnevie)\
**Post date:** [April 27, 2025, 7:56pm UTC](https://community.glideapps.com/t/how-to-select-data-for-a-given-user-when-using-export-csv-button/81552/5 "2025-04-27T19:56:23Z")

</div>

Dear @Nicolas_Joseph, your detailed answer has not only been helpfull, it totally resolved my issue.

I am very gratefull for your help. Glide community is amazing 🙂

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [May 4, 2025, 7:56pm UTC](https://community.glideapps.com/t/how-to-select-data-for-a-given-user-when-using-export-csv-button/81552/6 "2025-05-04T19:56:44Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
