Search code examples
google-apps-scriptlooker-studiogoogle-sites

How can I filter dashboard content based on User or Email?


I am trying to build a dashboard on Google Data Studio that automatically filters the data based on the user who is accessing the dashboard (using their Google account credentials). Here is some details: So this dashboard is supposed to show some aggregated data for employees but we want to limit the visibility and implement some access control so that each leader can only see the results for their own team. Below is a sample data set and a sample dashboard. I have tried creating filters based on leaders but couldn't find a way to link that to how the dashboard is being rendered.

P.S. I have a good understanding of JavaScript if there is a workaround using Google Apps Script. This dashboard will be deployed to a webpage on Google Sites so maybe we can control and manage the access that way.

Data Set (Google Sheets):

User Score Leader Email
1 8 Melissa [email protected]
2 6 Natalie [email protected]
3 9 Adam [email protected]
4 3 Melissa [email protected]
5 4 Natalie [email protected]
6 8 Adam [email protected]
7 4 Melissa [email protected]
8 8 Natalie [email protected]
9 4 Adam [email protected]

Output (where Score is aggregated by AVG):

Leader Record Count Score (AVG)
Adam 3 7
Natalie 3 6
Melissa 3 5

Expected Output is that the Leader Natalie only sees:

Leader Record Count Score (AVG)
Natalie 3 6

Google Data Studio report


Solution

  • It can be achieved using the Filter by email address feature:

    1. Click the Filter by Email button on the top left of the data source
    2. Tick (☑) Filter data by viewer email
    3. Select the Email field (which is this case is also Email)
    4. Click Allow when the Grant Consent dialog box pops up

    To demonstrate visually below, replaced a Leader (Natalie) and their Email ([email protected]) with an actual email, thus changing the values to Nimantha and [email protected] respectively.

    NOTE: After the steps, the Google Data Studio report can only be viewed by the people explicitly added and by the users shared, thus while the report used in the GIF below is set to publicly editable, it's only viewable by the emails shared and any other people given permission to view the report (although the data will still be confidential to only the specific shared email for each row of data). I have thus created another unfiltered report that's viewable by all users:

    Publicly editable Google Data Studio report (embedded Google Sheets data source) and a GIF to elaborate:

    gif