User defined parameter default value

Hey guys,
I am trying to find a solution for my problem:

We have a parameter used in different explores:

view: country {
  label: "Country"

  parameter: country_code {
    label: "Code"
    type: unquoted

    default_value: ""
    allowed_value: {
      label: "Country 1"
      value: "country_1"
    }
    allowed_value: {
      label: "Country 2"
      value: "country_2"
    }
    allowed_value: {
      label: "Country 3"
      value: "country_3"
    }
  }

We would like that for some users the parameter has one country as default value, for others another one. The complete option list should be visible for all users, only default value should differ.

I thought the best approach for this is to use an user attribute. But it seems that the default_value of a parameter object does nor support anything else than strings.

Does anyone have any ideas how to solve this problem?

Thank you

0 7 2,034
7 REPLIES 7

moebe
Participant V

Hi Adrian
you can solve this with user attributes.
But you can not use the allowed values.
You need to use the suggestions.

Hi Benjamin,

Thank you so much for your reply, but i am not completely sure that i understand your solution.
As far as i can see suggestions accept only strings or list of strings as values.

Can you give a bit more details about the solution you have in mind.
Thank you so much!

moebe
Participant V

Hi Adrian

parameter: test {
suggestions: [“Country1”, “Country2”, “Country3”]
type: string
default_value: “{{ _user_attributes[‘default_country’] }}”
}

This should give you a list of values (not like the “normal” param.
And the default value as user attribute should work

seems to work.
thank you very much

Have you tested this?

I have never successfully used user attributes in a parameter’s default_value

i made it work like this

view: country {
  label: "Country"

  parameter: country_code {
    label: "Code"
    suggestions: ["country_1", "country_2", "country_3"]
    type: unquoted
  }
}

explore: explore_test {

  join: country {}

  # Country filter should always be on
  always_filter: {
    filters: [
      country.country_code: "{{_user_attributes['default_country_code']}}"
    ]
  }
}

@Adrian_Triteanu does that work only when suggestions for parameter are defined? I have suggest_dimention instead of suggestions and it seems to not work

Top Labels in this Space
Top Solution Authors