Skip to content

A Quick Report expression meant to calculate 10% of qualifying records per group (for a sampling-count use case) just returns 0 or 0.1 per individual row instead of a meaningful rounded percentage-based count — wrapping the expression in ROUND() at the front doesn't fix it. What's missing?

Answer

The expression is missing aggregation entirely — without a GROUP BY and a SUM(), each individual row independently evaluates its own CASE expression to either 0 or 1, multiplied by 0.1, giving 0 or 0.1 per row rather than any meaningful group-level percentage. Add a GROUP BY on the relevant grouping column (such as a contract/site identifier), wrap the CASE expression in SUM(...) to total it across each group, and only then apply ROUND(...) around that summed value, specifying 0 decimal places, to get a properly rounded whole-number count representing roughly 10% of qualifying records within each group.

← Browse Reporting and analytics questions