Skip to main content

Hi, I want to use the button components to view KPI lists in Number / Percentage in the New View. For example, clicking button 1 will display KPIs in number and clicking button 2 will display KPIs in percentage. I know I can use enhanced variable but I'm not sure how to link them together. Any helps would be helpful!

Hello,

The solution with the 2 buttons:

  • You would need 2 variables as buttons doesn't seem to be able to handle OBJECT type variables (or I couldn't figure out how)
  • Variable 1: format_switch
  • Variable 2: format_switch_format (this is necessary to toggle between rounded number vs percentage format)
  • Button 1: Number format - add interactions to update both variables. format_switch should be set to number while format_switch_format should be set to ,.0f
  • Button 2: Percentage format - add interactions to update both variables. format_switch should be set to percentage while format_switch_format should be set to % (for whatever reason, this would include 6 digits but I couldn't make it work with the #.#% format)
  • Set up the KPI list as follows:

KPI 1: CASE

  WHEN '${format_switch}' = 'number'

  THEN KPI("kpi_1_number")

  ELSE KPI("kpi_1_percentage") END

Set the formatting to custom and add the reference to the other variable: ${format_switch_format}imageDo the same for the next and following KPIs:

imageimageimage


I think there is a better solution with using and Input dropdown and an OBJECT type variable (switch_test)

In the Input dropdown, you would add Manual Input / Attributes & Metrics

The setup for dropdown items:

For Number, the PQL is 'Number' and Format is Rounded Number.

For Percentage, the PQL is "Percentage' and Format is Percentage with Decimals.

Interaction: save user selection to the variable switch_test

imageSetting up the KPI list similarly uses a CASE WHEN statement:

CASE

  WHEN ${switch_test.pql} = 'Number'

  THEN KPI("kpi_1_number")

  ELSE KPI("kpi_1_percentage")

END

Then the Format again Custom Format with value: ${switch_test.format}

imageIt's good practice to copy the current value of the switch_test variable to the default value section after you first selected the version you want as default.

This avoids display issues later on.

image 

This solution is a bit easier to maintain as it only requires 1 variable and it can handle the percentage format nicely.

imageimage


Hello,

The solution with the 2 buttons:

  • You would need 2 variables as buttons doesn't seem to be able to handle OBJECT type variables (or I couldn't figure out how)
  • Variable 1: format_switch
  • Variable 2: format_switch_format (this is necessary to toggle between rounded number vs percentage format)
  • Button 1: Number format - add interactions to update both variables. format_switch should be set to number while format_switch_format should be set to ,.0f
  • Button 2: Percentage format - add interactions to update both variables. format_switch should be set to percentage while format_switch_format should be set to % (for whatever reason, this would include 6 digits but I couldn't make it work with the #.#% format)
  • Set up the KPI list as follows:

KPI 1: CASE

  WHEN '${format_switch}' = 'number'

  THEN KPI("kpi_1_number")

  ELSE KPI("kpi_1_percentage") END

Set the formatting to custom and add the reference to the other variable: ${format_switch_format}imageDo the same for the next and following KPIs:

imageimageimage

Thank you. thats very helpful. I somehow managed to figure it out but having trouble to showing the number in a different format. This is great thanks!


Hello,

The solution with the 2 buttons:

  • You would need 2 variables as buttons doesn't seem to be able to handle OBJECT type variables (or I couldn't figure out how)
  • Variable 1: format_switch
  • Variable 2: format_switch_format (this is necessary to toggle between rounded number vs percentage format)
  • Button 1: Number format - add interactions to update both variables. format_switch should be set to number while format_switch_format should be set to ,.0f
  • Button 2: Percentage format - add interactions to update both variables. format_switch should be set to percentage while format_switch_format should be set to % (for whatever reason, this would include 6 digits but I couldn't make it work with the #.#% format)
  • Set up the KPI list as follows:

KPI 1: CASE

  WHEN '${format_switch}' = 'number'

  THEN KPI("kpi_1_number")

  ELSE KPI("kpi_1_percentage") END

Set the formatting to custom and add the reference to the other variable: ${format_switch_format}imageDo the same for the next and following KPIs:

imageimageimage

Hi, I managed to show the number and percentage in the format I want - hope that helpsimageimage


Reply