Create a drop-down from column headers

I'm trying to create a second drop down that encapsulates all of the column headers. I.e., pare down a table by filtering by row, and then filtering by column. Basically, get this table...

Screenshot 2024-04-28 at 9.42.17 PM.png

... down to a 1v1 level. E.g., select "Jack Black" in the drop-down shown, but then also select "Banquet Beer" from a theoretical second drop-down to narrow the table down to just "Jack Black" in the row, and "Banquet Beer" in the column. Like this:

Screenshot 2024-04-28 at 9.44.42 PM.png

As of right now, if I select a Name in the drop-down, it'll just filter the table to one row with all the columns. I just need a way to filter on the column headers in a "Name 2" drop-down. Is this possible? Thank you!

Dashboard view: https://lookerstudio.google.com/u/0/reporting/eaa804c3-0906-4f3f-827f-314a9b0ad5bb/page/p_y4d2ahgy5c

 

1 2 1,086
2 REPLIES 2

Hey,

Please don't blame me lazy but I ask claude for this question, and the answer sounds reasonable. I will try it some time soon. In case the problem is still relevant for you, have a look:
-----------------------------------

Yes, it's possible to create this kind of dynamic column selection in Looker Studio (formerly known as Google Data Studio). Here's how you can set it up:

1. Create a Parameter:
First, you need to create a parameter that will serve as your dropdown menu for column selection.

- Click on "Add a control" in the top menu
- Choose "Drop-down list"
- In the Data tab of the control settings:
- Set "Control field" to "Create Field"
- Add your column names as options (e.g., "Column1", "Column2", "Column3")
- Give your parameter a name (e.g., "Column Selector")

2. Create a Calculated Field:
Next, create a calculated field that will return the value of the selected column.

- Go to "Resource" > "Manage added data sources" > "Add a field"
- Use a CASE statement to return the appropriate column based on the parameter value. For example:

```
CASE
WHEN ${Column Selector} = "Column1" THEN Column1
WHEN ${Column Selector} = "Column2" THEN Column2
WHEN ${Column Selector} = "Column3" THEN Column3
ELSE NULL
END
```

- Name this calculated field (e.g., "Selected Column")

3. Create the Table:
Now, create your table visualization:

- Add a table chart to your report
- In the Data tab of the table settings:
- Add your "Selected Column" calculated field to the Dimension section
- You can add any relevant metrics if needed

4. Configure the Table:
In the Style tab of the table settings:
- Set "Show" to only display the columns you want (in this case, just your "Selected Column")

Now, when you select a different option from your dropdown parameter, the table will update to show only the selected column.

Keep in mind:
- This method works best when your columns have similar data types. If they're very different (e.g., mixing dates, numbers, and text), you might need to adjust your calculated field to handle these differences.
- If you have a large number of columns, manually creating the CASE statement could be cumbersome. In such cases, you might need to look into more advanced solutions or prepare your data differently before importing it into Looker Studio.
- The performance of your report might be affected if you're working with a large dataset and frequently switching between columns.

 

@papelr 

Here an original article - written by a human being - describing how to create a metric selector.

https://how.withlookerstudio.com/advanced-controls/20230209-metric-selector-to-control-measure-displ...

Feel to tell me if you need more info, otherwise you can accept this answer as a solution. 

Mehdi