Skip to content

Commit 0342adf

Browse files
authored
Merge pull request #463 from Ed9uard/fix-multiple-filters-issue-461
Fix: support multiple filters on widgets (fixes #461)
2 parents 16d1ded + 375b781 commit 0342adf

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/app/components/widgets/base-widget.class.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,18 +2138,25 @@ export class BaseWidget implements OnInit, OnDestroy {
21382138
private applyFilters(filters: IFilter[]) {
21392139
const active = filters.filter(flt => {
21402140
// Skip all apply variable filters
2141-
if (flt.action === 'applyVariable') {
2141+
if (flt.action === 'applyVariable') {
21422142
return false;
21432143
}
21442144
return flt.value !== '';// && !flt.isInterval
21452145
});
21462146

2147+
if (active.length === 0) {
2148+
return '';
2149+
}
21472150
if (active.length === 1) {
2148-
// One dimension
2149-
return ' %FILTER ' + this.getFilterString(active[0])
2150-
} else {
2151-
const strings = active.map(flt => this.getFilterString(flt));
2152-
return ' %FILTER NONEMPTYCROSSJOIN(' + strings.join(',') + ')';
2151+
return ' %FILTER ' + this.getFilterString(active[0]);
2152+
}
2153+
2154+
// Nested NONEMPTYCROSSJOIN for any number of filters > 1
2155+
const strings = active.map(flt => this.getFilterString(flt));
2156+
let crossjoin = strings[0];
2157+
for (let i = 1; i < strings.length; i++) {
2158+
crossjoin = `NONEMPTYCROSSJOIN(${crossjoin},${strings[i]})`;
21532159
}
2160+
return ' %FILTER ' + crossjoin;
21542161
}
21552162
}

0 commit comments

Comments
 (0)