Hi.
I need for requirement to block the combo box for a date column with always_filter: because we want to give the option to the user change the dates but we want to restrict to just select is before .
I tried using many ways.
explore: view_name {
always_filter: {
filters: [wire_modified_date: "before ({{ _user_attributes['wire_modified_date'] }})" ]
}
}
Also I tried to use with parameters.
parameter: date_selector {
type: date_time
label: "Date Selector"
description: "Select a specific date and time"
default_value: "2024-01-01T00:00:00" # Default value for the parameter
}
parameter: allowed_date_operators {
type: string
allowed_value:
{label: "before"
value: "before"
}
default_value: "before" # Hide this parameter from users
}
explore: view_name {
always_filter: {
filters: [wire_modified_date: "${allowed_date_operators} ${date_selector}"]
}
}
Does any one knows how to resolve this.
Regards.
Hey @Fterrazasidt !
It depends on what is the expected behaviour.
If you want to prevent some specific person to see after specific date, user attribute with type date make sense to be used.
The only thing that I would suggest is to use instead of always_filter, sql_always_where parameter:sql_always_where | Looker | Google Cloud.
Here you have an example where I created a user attribute called date_test and with this statement I'm blocking the users to see anything after this date:
explore: order_items {
sql_always_where: ${order_items.created_date}<'{{ _user_attributes['date_test'] }}' ;;
}
Here I assign the value to the user attribute to my user:
This is how it appears afterwards on the SQL part. You can see that I'm not filtering on any date inside of the Explore interface. But it's going to restrict any dates after the one that you assigned to specific user or group of users.
Pay attention that in the future you will need to update those values!
There are other ways to set the restriction.
I can suggest them if you want to share more details :).
Hope it helps!!
Hi