fix: normalize percentage metric filter values for correct comparison#9068
Draft
fix: normalize percentage metric filter values for correct comparison#9068
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the metrics filter not functioning for percentage types (APP-779).
When a measure uses percentage format (
format_preset: "percentage"orformat_d3with%), 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: AddedisMeasurePercentFormat()utility that detects percentage-formatted measures by checkingformatPreset === "percentage"orformatD3containing%MeasureFilterForm.svelte: Converts between display values (×100) and raw values (÷100) for percentage measures. Shows a%suffix label next to the threshold input fieldsMeasureFilterBody.svelte: Displays filter chip values multiplied by 100 with%suffix for percentage measures (e.g., "< 80%" instead of "< 0.8")MeasureFilter.svelte: Passes theisPercentflag fromMeasureFilterItemto both the form and body componentsmeasure-filters.ts(selectors),Filters.ts,filter-state.ts,filter-manager.ts: SetisPercentonMeasureFilterItemfrom the measure spec at all creation points (explore dashboards, canvas, scheduled reports)How it works
The fix operates at the UI boundary level:
MeasureFilterEntrystores raw decimal values (e.g., "0.8") — same as beforemapMeasureFilterToExpr/mapExprToMeasureFilterfunctions or URL/proto serialization — backward compatibleCloses APP-779
Checklist:
Linear Issue: APP-779