Parameters - Unexpected behaviour

Hi all,

I’m using a Parameter that I pass into a Dynamic Measure and into an HTML field that I use as a separator within a dashboard:

The parameter looks like this:

  parameter: handset_sales_picker {

    description: "To toggle betweeen warehouse handset sales or platform handset sales. Use with Dynamic Handset Sales"

    hidden: no

    type: unquoted

    default_value: ""

    allowed_value: {

      label: "Warehouse"

      value: "handsets_sales"

    }

    allowed_value: {

      label: "Platform"

      value: "plat_handset_sales"

    }

  }

The dynamic measure looks like this:

  measure: dynamic_handset_sales {

    description: "It allows to toggle between Total Handset Sales and Total Platform Handset Sales"

    hidden: no

    group_label: "Handset Sales - Dynamic"

    label: "{% if handset_sales_picker._parameter_value == 'handsets_sales' %}  Total Handset Sales

            {% elsif handset_sales_picker._parameter_value == 'plat_handset_sales' %}  Total Platform Handset Sales

            {% endif %}"

    group_item_label: "Dynamic Total Handset Sales"

    type: number

    sql:

      {% if handset_sales_picker._parameter_value == 'handsets_sales' %} ${total_handset_sales}

      {% elsif handset_sales_picker._parameter_value == 'plat_handset_sales' %} ${total_plat_handset_sales}

      {% endif %}

    ;;

    html:

      {% if handset_sales_picker._parameter_value == 'handsets_sales' %}  {{ total_handset_sales._rendered_value }}

      {% elsif handset_sales_picker._parameter_value == 'plat_handset_sales' %}  {{ total_plat_handset_sales._rendered_value }}

      {% endif %}

    ;;

  }

The HTML field looks like this, bear in mind this dimension is within a different View to the one in which the Parameter and Dynamic  Measure have been defined

  dimension: subheader_test {

    html:<div style=

          "background: linear-gradient(180deg, #EB5F8E, #EB5F8E);

          color: #000000;

          {% if title_for_subheader_value._value  != "" and comment_for_subheader_value._value  != "" %} height: 160px !important;

          {% else %} height: 120px !important; {% endif %}

          font-weight: bolder;

          align-self: center;

          text-align: center;

          padding-left: 10px;

          padding-top: 30px;

          padding-bottom: 30px;

          font-family: 'helvetica';

          font-size: 30px">

          <div style="float:left;"><img src="https://www.giffgaff.design/images/DS-main-img-mobile-20200304@2x.png" height="80" /></div>

          <div style="float:right;"><img src="https://www.giffgaff.design/images-DS-main-img-mobile-20200304@2x.png" height="80" /></div>

          {% if fact_total_marketing.handset_sales_picker._parameter_value == 'handsets_sales' %}  <h>{{title_for_subheader_value._rendered_value}} -  Warehouse</h>

          {% elsif fact_total_marketing.handset_sales_picker._parameter_value  == 'plat_handset_sales' %}  <h>{{title_for_subheader_value._rendered_value}} - Platform</h>

          {% else%} <h>{{title_for_subheader_value._rendered_value}}</h>

          {% endif %}

          <p style = "font-weight: normal; text-align: left; font-size: 18px;">{{comment_for_subheader_value._rendered_value}}</p>

        </div> ;;

    sql: 1 ;;

  }

   

The setup is, the Parameter is a filter in the dashboard, that updates the measures and the text in the HTML field.

Although I noticed that if I change the ‘allowed values’ (i.e. ‘handsets_sales’ & ‘plat_handset_sale’) in the Parameter definition, the query breaks and says it can’t find such value (whatever is the value I put in the Parameter, for instance could be ‘handset’). How could this be possible? I thought that I could put any value I want in the Parameter. In fact I was capable of doing so, but when I brought the Parameter into the HTML field, the field would break. 

Coincidentally I noticed that the value names ‘handsets_sales’ & ‘plat_handset_sale’ are also dimensions defined in the View


  dimension: handsets_sales {

    hidden: yes

    type: number

    sql: ${TABLE}.handsets_sales ;;

  }

  dimension: plat_handset_sales {

    hidden: yes

    type: number

    sql: ${TABLE}.plat_handset_sales ;;

  }

Does anyone knows the reason for this? It’s very odd to me, and I’m a bit worried that I could have issues in the future.

Thanks,

0 1 142
1 REPLY 1

Hiya!

When you say you change allowed values in parameter definition - do you also change it everywhere in your measures? 

Because there are hardcoded values in the if statement like here  

 sql:

{% if handset_sales_picker._parameter_value == 'handsets_sales' %} ${total_handset_sales}

{% elsif handset_sales_picker._parameter_value == 'plat_handset_sales' %} ${total_plat_handset_sales}

{% endif %}

;;

and there is no {% else %} statement, so when those two first conditions are not met, it is unknown what should be done, there is no rule for it.

Top Labels in this Space
Top Solution Authors