balajij8
Esteemed Contributor II

You can follow below to create a dynamic Percent that responds seamlessly to global filter selections

You can tie Global Filter directly to a Parameter in the Query and it allows recalculating the SUM only for the selected categories.

  • Modify Query: Update your dataset query to include a clause with a multi select parameter for categories.
SELECT
  category,
  region,
  emissions,
  -- Percent of column total (by region)
  emissions
    * 1.0
    / SUM(emissions) OVER (PARTITION BY region) AS pct_of_column_total,
  -- Percent of grand total
  emissions
    * 1.0
    / SUM(emissions) OVER () AS pct_of_grand_total
FROM
  emission_data
WHERE
  :category_filter IS NULL
  OR size(:category_filter) = 0
  OR array_contains(:category_filter, category)
  • Set up the Global Filter: On Dashboard, add a Filter, set it to Query Parameter and map it to Category_filter

The query fetches the data with only the selected categories and pivot table will perfectly reflect 100% across the remaining items.