Search code examples
looker-studio

Custom dropdown control which drives which field is used in another control


I am building a report in Looker Studio. I have two fields in my data source representing the year, one which has the calendar year and the other the fiscal year. I want to enable filtering the report by either. However, this means that depending on the user's selection, the year dropdown field will change (it is conditionally based on the user's selection of fiscal or calendar year). How do I go about doing this?

I do not have a specific field that aligns to Fiscal vs. Calendar (these are distinct fields which are available for every row). Is this what a parameter is for? If so, how does this control then set the control field for another control?


Solution

  • Yes, this is what parameters are for. First, create a new parameter as "Year Type". Enter "calendar" and "fiscal" as possible values. Now go to your data source and create a new calculated field there (click "Add Field" in the screen that shows all fields of your data source). Name the field "Fiscal or Calendar Year". Define it as CASE WHEN Year Type = "calendar" THEN <calendar year field> ELSE <fiscal year field> END

    Now add a control to your report. Choose the type "drop down list". In Set-up area on the right, set "control field" to the parameter you just created ("Year Type"). This will now let you choose between fiscal and commercial.

    Now add another drop down control. Set the control field to the field you just created ("Fiscal or Calendar Year"). Now when you set "fiscal" in the first drop down, the second drop down will show fiscal years, otherwise calendar years.

    Make sure to use that calculated field as a dimension in your tables / diagrams etc. as well.