Question

Customizing links based on value of dimension

  • 5 January 2017
  • 0 replies
  • 820 views

Userlevel 3

Overview


Customizing the links menu based on the values of the dimension.


Problem


Suppose you have a Bar Chart showing some measure against a dimension with values Category A, Category B, etc., and you would like to have a link from the Bar Chart to a custom Dashboard for each category, by clicking on the relevant bar.


What you need is a link that takes different values based on the value of the Dimension.



Note: this is not the same as having a link to a dashboard with a filter on the category, here we are talking about completely different dashboards.



Solution


First of all create your custom Dashboards.


Next create a new url_field dimension, which applies a CASE statement to the Category dimension and returns a URL string


dimension: url_field {
hidden: yes
type: string
sql:
CASE
WHEN ${category} = 'Category A' THEN ('/dashboard/8')
WHEN ${category} = 'Category B' THEN ('/dashboard/9')
ELSE Null
END ;;
}

And also a custom label_field dimension


dimension: label_field {
hidden: yes
type: string
sql:
CASE
WHEN ${category} = 'Category A' THEN ('Category A Dashboard')
WHEN ${category} = 'Category B' THEN ('Category B Dashboard')
ELSE Null
END ;;
}

Then for the dimension Category, we add link labels and urls based on the values of these dimensions, using {{view_name.field._value}} to access the values of other fields, like this


dimension: category {
type: string
sql: ${TABLE}.category
drill_fields: [subcategory]
link: {
label: "{{view_name.label_field._value}}"
url: "{{view_name.url_field._value}}"
}
}

This will now give a custom drill menu for each category, and for categories without a dashboard, where we defined Null, no link will be displayed at all.



0 replies

Be the first to reply!

Reply