Qlik仪表板:点击Multi KPI动态切换趋势图表的实现可行性咨询
Answer
Absolutely! This is totally doable with Qlik's built-in features—no JavaScript required, which is perfect for a new Qlik dashboard builder. Here's a step-by-step breakdown to implement the click-to-switch trend chart:
Core Concept
We'll use a variable to control which metric the trend chart displays, then add a click action to each Multi KPI that updates this variable to its corresponding metric.
Step 1: Create a Control Variable
- Go to App overview > Edit > Variables (or use the variable editor shortcut).
- Create a new variable, e.g.,
vSelectedKpiMetric. - Set its initial value to the metric expression of your first Multi KPI (wrap it in single quotes to treat it as a string). For example:
This ensures the trend chart loads with your first KPI's trend by default.'Sum(TotalSales)'
Step 2: Configure the Trend Chart (GRAPH 1)
- Add your line/bar trend chart to the dashboard, set its dimension to your 13-week time field (e.g.,
Week). - For the chart's metric, use the variable to dynamically pull the selected KPI's data. Enter this expression in the metric field:
This tells Qlik to evaluate the variable's current value as the metric for the chart.$(vSelectedKpiMetric)
Step 3: Add Click Actions to Each Multi KPI
- Edit any of your Multi KPIs, go to the Actions tab.
- Click Add Action > Set Variable.
- In the action settings:
- Select your variable
vSelectedKpiMetric - Set the Value to the exact metric expression used in this Multi KPI (again, wrap in single quotes). For example, if this KPI tracks profit, use:
'Sum(TotalProfit)' - Set the Trigger to On Click (this avoids conflicting with your existing double-click jump action).
- Select your variable
- Repeat this for all 11 Multi KPIs, updating the value to match each KPI's unique metric.
Optional Optimizations
- If you're using Qlik's Metric Library to store your KPIs, you can reference the metric's ID directly instead of copying expressions. For example:
This keeps your setup cleaner and avoids duplicate code.'=Metric("MetricID-123")' - Add a visual indicator (like a border color change) to the selected Multi KPI using conditional formatting tied to the variable. For example, set the KPI's border color to blue when
vSelectedKpiMetric = 'Sum(TotalSales)'.
Testing
Save your changes, then test clicking each Multi KPI—your trend chart should instantly switch to display the 13-week trend for that KPI, while double-clicking still triggers your existing dashboard jump.
内容的提问来源于stack exchange,提问作者Michael Owen
相关产品推荐
相关产品推荐

