Skip to content

An open source alternative to Tableau. Embeddable visual analytic

chore: change distinct count logic (#236)

islxyqwedc63c1c34b84
diff --git a/packages/graphic-walker/src/computation/index.ts b/packages/graphic-walker/src/computation/index.ts
index 2dfae86b..51026fbc 100644
--- a/packages/graphic-walker/src/computation/index.ts
+++ b/packages/graphic-walker/src/computation/index.ts
@@ -139,16 +139,32 @@ export const fieldStat = async (
query: [
{
op: 'aggregate',
- groupBy: [],
+ groupBy: [field.fid],
measures: [
{
- field: field.fid,
- agg: 'distinctCount',
- asFieldKey: TOTAL_DISTINCT_ID,
+ field: '*',
+ agg: 'count',
+ asFieldKey: COUNT_ID,
},
+ ],
+ },
+ ],
+ },
+ {
+ type: 'view',
+ query: [
+ {
+ op: 'aggregate',
+ groupBy: [],
+ measures: [
{
field: '*',
agg: 'count',
+ asFieldKey: TOTAL_DISTINCT_ID,
+ },
+ {
+ field: COUNT_ID,
+ agg: 'sum',
asFieldKey: 'count',
},
],
diff --git a/packages/graphic-walker/src/fields/filterField/tabs.tsx b/packages/graphic-walker/src/fields/filterField/tabs.tsx
index 754f86d4..af69b160 100644
--- a/packages/graphic-walker/src/fields/filterField/tabs.tsx
+++ b/packages/graphic-walker/src/fields/filterField/tabs.tsx
@@ -295,7 +295,7 @@ const useVisualCount = (
if (!field.rule || (field.rule.type !== 'one of' && field.rule.type !== 'not in') || !metaData) return;
setSelectedValueSum(0);
onChange({
- type: currentSum === metaData.valuesMeta.total ? 'one of' : 'not in',
+ type: currentCount === metaData.valuesMeta.distinctTotal ? 'one of' : 'not in',
value: new Set(),
});
}, [field.rule, onChange, metaData]);