Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
sandp707
Contributor III
Contributor III

Create filter with continuous numbers

Hello everyone,

How to create a filter based on below conditions.

I have a column with values 1,2,3,4….,52

I need filter based on

if = 1 then delivery 1

if <= 4 then delivery 4 (this should also include 1)

if <= 6 then delivery 6 (this should include both the above conditions)

Thanks

Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

You need to create a separate table to associate WeekNo with the Deliveries Grouping

So you will have FactTable with Global_Key and WeekNo   and another Table with a one to Many relationship with the Deliveries grouping

as below

You can do it in Two Ways

1)    

 

 

FactTable:
Load GlobalKey,WeekNo
From  SomeSourceTable;


WeekGroup:
Load 
WeekNoFrom+iterno()-1  as WeekNo
,Deliveries
While WeekNoFrom+iterno()-1 <=WeekNoTo
;
load * inline [
WeekNoFrom,WeekNoTo,Deliveries
1,1,Last1Week
1,4,Last4Week
1,6,Last6Week
1,13,Last13Week
1,26,Last26Week
1,52,Last52Week
];

Concatenate(WeekGroup)
Load Distinct WeekNo,'ALL'
Resident FactTable;

 

 

 

 

Option 2:

 

 

 

FactTable:
Load GlobalKey,WeekNo
From  SomeSourceTable;


WeekGroup:
Load Distinct WeekNo,'Last1Week' as Deliveries
Resident FactTable
Where WeekNo=1;

Concatenate(WeekGroup)
Load Distinct WeekNo,'Last4Week' as Deliveries
Resident FactTable
Where WeekNo<=4;

Concatenate(WeekGroup)
Load Distinct WeekNo,'Last6Week' as Deliveries
Resident FactTable
Where WeekNo<=6;
.
.and
.so
.on
.for each grouping
.
.

Concatenate(WeekGroup)
Load Distinct WeekNo,'ALL'
Resident FactTable;

 

 

 

 

Capture.PNG

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
BrunPierre
Partner - Master
Partner - Master

As per the syntax  if(condition , then [, else]) like this

If(Column = 1 ,'Delivery 1',

If(Column <= 4 ,'Delivery 4',

If(Column <= 6 ,'Delivery 6'))) as Filter

sandp707
Contributor III
Contributor III
Author

Hello Brun,

I am also using the same logic, but it is showing the results as below.

where for Delivery 1 it is working fine,

for delivery 4 it should show (1,2,3,4) but it is showing (2,3,4)

for delivery 6 it should show (1,2,3,4,5,6) but it is showing (5,6) and same for other numbers

sandp707_0-1670395140353.png

 

Result:

sandp707_1-1670395207622.png

Thanks

vinieme12
Champion III
Champion III

You need to create a separate table to associate WeekNo with the Deliveries Grouping

So you will have FactTable with Global_Key and WeekNo   and another Table with a one to Many relationship with the Deliveries grouping

as below

You can do it in Two Ways

1)    

 

 

FactTable:
Load GlobalKey,WeekNo
From  SomeSourceTable;


WeekGroup:
Load 
WeekNoFrom+iterno()-1  as WeekNo
,Deliveries
While WeekNoFrom+iterno()-1 <=WeekNoTo
;
load * inline [
WeekNoFrom,WeekNoTo,Deliveries
1,1,Last1Week
1,4,Last4Week
1,6,Last6Week
1,13,Last13Week
1,26,Last26Week
1,52,Last52Week
];

Concatenate(WeekGroup)
Load Distinct WeekNo,'ALL'
Resident FactTable;

 

 

 

 

Option 2:

 

 

 

FactTable:
Load GlobalKey,WeekNo
From  SomeSourceTable;


WeekGroup:
Load Distinct WeekNo,'Last1Week' as Deliveries
Resident FactTable
Where WeekNo=1;

Concatenate(WeekGroup)
Load Distinct WeekNo,'Last4Week' as Deliveries
Resident FactTable
Where WeekNo<=4;

Concatenate(WeekGroup)
Load Distinct WeekNo,'Last6Week' as Deliveries
Resident FactTable
Where WeekNo<=6;
.
.and
.so
.on
.for each grouping
.
.

Concatenate(WeekGroup)
Load Distinct WeekNo,'ALL'
Resident FactTable;

 

 

 

 

Capture.PNG

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
sandp707
Contributor III
Contributor III
Author

Both the solutions are working fine.

Thanks a lot