Category / Section
How to Calculate Percentile and Visualize Data Using Dashboard Parameters
Published:
To calculate percentiles and use them effectively within a dashboard, follow the steps outlined below. These steps will guide you in creating a dashboard parameter, writing the appropriate query, defining an expression, and setting up the visualization.
Steps to Calculate Percentile and Use It in the Dashboard:
-
Create a Dashboard Parameter:
- Navigate to the query designer page within your dashboard tool.
- Create a parameter that will be used in later steps.
-
Write the Query for Percentile Calculation:
Use the following SQL query to calculate the 90th percentile of theamountfield:SELECT percentile_cont(0.90) WITHIN GROUP (ORDER BY amount) AS p90_cont FROM sales -
Define an Expression Using the Parameter:
Create an expression that references the dashboard parameter. The following expression can be used:
IF([amount] > @{{:Parameter2}}, [amount], 0)- Here,
Parameter2refers to the dashboard parameter created in Step 1.
- Here,
-
Use the Expression in the Dashboard Widget:
- Assign the defined expression to the widget you wish to visualize.
- Update the widget’s aggregation setting to none and filter the data with greater than Zero value
- The resultant widget data
- Assign the defined expression to the widget you wish to visualize.