Skip to content

fix: normalize percentage metric filter values for correct comparison#9068

Draft
ericokuma wants to merge 1 commit intomainfrom
cursor/APP-779-percentage-filter-functionality-c8c1
Draft

fix: normalize percentage metric filter values for correct comparison#9068
ericokuma wants to merge 1 commit intomainfrom
cursor/APP-779-percentage-filter-functionality-c8c1

Conversation

@ericokuma
Copy link
Contributor

Summary

Fixes the metrics filter not functioning for percentage types (APP-779).

When a measure uses percentage format (format_preset: "percentage" or format_d3 with %), the underlying data is stored as a decimal (e.g., 0.8 for 80%). Previously, users entering "80" in the filter threshold would send 80 to the backend instead of 0.8, making the filter ineffective.

Changes

  • measure-filter-entry.ts: Added isMeasurePercentFormat() utility that detects percentage-formatted measures by checking formatPreset === "percentage" or formatD3 containing %
  • MeasureFilterForm.svelte: Converts between display values (×100) and raw values (÷100) for percentage measures. Shows a % suffix label next to the threshold input fields
  • MeasureFilterBody.svelte: Displays filter chip values multiplied by 100 with % suffix for percentage measures (e.g., "< 80%" instead of "< 0.8")
  • MeasureFilter.svelte: Passes the isPercent flag from MeasureFilterItem to both the form and body components
  • measure-filters.ts (selectors), Filters.ts, filter-state.ts, filter-manager.ts: Set isPercent on MeasureFilterItem from the measure spec at all creation points (explore dashboards, canvas, scheduled reports)

How it works

The fix operates at the UI boundary level:

  1. The MeasureFilterEntry stores raw decimal values (e.g., "0.8") — same as before
  2. The form displays values multiplied by 100 (e.g., "80") and converts back (÷100) on submit
  3. The filter chip displays values multiplied by 100 with "%" suffix
  4. No changes to the core mapMeasureFilterToExpr/mapExprToMeasureFilter functions or URL/proto serialization — backward compatible

Closes APP-779

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Linear Issue: APP-779

Open in Web Open in Cursor 

When a measure uses percentage format (format_preset: 'percentage' or
format_d3 with '%'), the underlying data is stored as a decimal (e.g.,
0.8 for 80%). Previously, users entering '80' in the filter would send
80 to the backend instead of 0.8, making the filter ineffective.

Changes:
- Add isMeasurePercentFormat() utility to detect percentage-formatted measures
- Add isPercent flag to MeasureFilterItem, set from measure spec
- MeasureFilterForm: convert display values (×100) and raw values (÷100)
  for percentage measures, show '%' suffix on input fields
- MeasureFilterBody: display values multiplied by 100 with '%' suffix
  for percentage measures on the filter chip
- Update all filter item creation points (explore, canvas, scheduled reports)
  to propagate the isPercent flag

Resolves APP-779

Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants