always_filter: how to block the combo box for just before

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.

1 2 501
2 REPLIES 2

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:dsimeonova_1-1708528984414.png

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.
 dsimeonova_0-1708528943487.png

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 

dsimeonova

Hi @dsimeonova  thank you for the suggestion but for this case I need to have the option for the user to change the date and try to personalize the combo box option to just select is before , (not option to change combobox) but with the option to change date.
Fterrazasidt_0-1709045381301.png

 

 

Top Labels in this Space