Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
mandarchichkar
Contributor II
Contributor II

Fetch records based on "OR" condition between two visual filters

I want to fetch records in Table format based on "OR" condition between two visual filters in Qlik senseQlik Sense Query.jpg

In Above Image , Left side (Table A) is input data and Right side is expected output based on Filters (State=Maharashtra; Publish Year=2022-02)

Labels (5)
5 Replies
BrunPierre
Partner - Master
Partner - Master

Hi, either in the load script ...

[Table A]:
LOAD State,
[Publish Year]
FROM
Where State = 'Maharashtra' or [Publish Year] = '2022-02' ;

Or with this, while hiding the expression column under the presentation tab
=Count(DISTINCT{$<State={'Maharashtra'}>+<[Publish Year]={'2022-02'}>} State & [Publish Year])

mandarchichkar
Contributor II
Contributor II
Author

Thanks @BrunPierre ,

Here, user will select the filter values on run time. Just for understanding the example here, I have selected value as "Maharashtra" and "2022-02". But Ideally user will select these filter values from Filter Pane (Drop down Multiselect Filter)

Also If I use this hardcoded filter in Load Script, then I will not be able to load complete data from table. It will load data only for  State = 'Maharashtra' or [Publish Year] = '2022-02' 

 

Or
MVP
MVP

Assuming field selection is mandatory (not selecting a value in the context of OR means selecting all values, after all), I would set up an island table for each of these filters and then use a set along the lines of the below.

Load * INLINE [
Dim, Measure
A, 1
A, 2
B, 3
C, 4
C, 5
C, 6
D, 7
D, 8
];

Load * INLINE [
Dim1
A
B
C
D
];

Load * INLINE [
Measure1
1
2
3
4
5
6
7
8
];

 

Count({ <Dim = p(Dim1)>+<Measure = p(Measure1)> } Measure)

mandarchichkar
Contributor II
Contributor II
Author

Thanks @Or 

But here my use case is something different. Can you please check and let me know if you have any solution.

Or
MVP
MVP

Unfortunately, since you haven't explained why this does not work for you, I have no idea what else might work for your specific use case. The solution suggested should work for the situation you described in your original point, and generally speaking, it is neutral to pretty much everything else in your app so it's hard for me to think of a use case it would not apply to.

If your issue is with the island tables, you could consider using either variables or multiple states instead, but the end solution would be the same.