Skip to main content
Announcements
Get Ready. A New Qlik Learning Experience is Coming February 17! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
CHRIS_Singa
Contributor III
Contributor III

Intervalmatch with 2 dimensions

Hello,

I hope you are all doing good

Very quick question, How we can use intervalmatch for  dimensions ?

Country Sales Quantity
France 40 10
Belgium 90 60
Italy 20 80
UK  70

 

40

 

I have the above table and would like to use intervalmatch for the  2 dimensions ( sales , quantity)

I want to match the table above with the the table below using intervalmatch function.

How can I make it possible please ?

The table with intervalmatch looks like this : 

Intervalmatch table
Class value Category
0-50 Low
51-100 High
8 Replies
Kushal_Chawda

@CHRIS_Singa  What is the output you need? Can you please elaborate?

CHRIS_Singa
Contributor III
Contributor III
Author

 
CHRIS_Singa
Contributor III
Contributor III
Author

I have attached the image for what I really want to achieve. I just want to range sales and quantity according the class value in my other tables using intervalmatch because it is numeric

Kushal_Chawda

@CHRIS_Singa  If your class values are fixed and not going to change, simplest way will be creating if conditions in your data like below

LOAD  *,

            if ( Sales >=0 and Sales <=50, dual('0-50',1),
            if ( Sales >=51 and Sales <=100, dual('51-100',2))) as SalesClass,

           if ( Quantity >=0 and Quantity <=50, dual('0-50',1),
            if (Quantity >=51 and Quantity <=100, dual('51-100',2))) as QuantityClass,

            if ( Sales >=0 and Sales <=50, 'Low',
            if ( Sales >=51 and Sales <=100, 'High')) as SalesCategory,

            if (Quantity >=0 and Quantity <=50, 'Low',
            if (Quantity >=51 and Quantity <=100, 'High')) as QuantityCategory,

FROM Table;

CHRIS_Singa
Contributor III
Contributor III
Author

This was just an example, I got too much class value

It could take too much time. I cannot use Intervalmatch function or applymap in this case ? please 

Kushal_Chawda

@CHRIS_Singa  how many values do you have and how wide is the range is? for example are these ranges in millions? depending on that I can suggest other ways

CHRIS_Singa
Contributor III
Contributor III
Author

This is my range : 

Range
Class value  
0-50  
51-100  
101-102 This is where I can spend too much time
 if I use the condition function IF
103-104
105-106
106-107
107-108
108-109
109-110
110 up to 150 following 1 step difference
Kushal_Chawda

@CHRIS_Singa  try below

map_class:
mapping Load From +IterNo()-1 as Number,
                       [Class value]
while From +IterNo()-1 <= To;
load trim(SubField([Class value],'-',1)) as From,
        trim(SubField([Class value],'-',2)) as To ,
       [Class value],
       Category
FROM InterVal_Table;

map_category:
mapping Load From +IterNo()-1 as Number,
                       Category
while From +IterNo()-1 <= To;
load trim(SubField([Class value],'-',1)) as From,
        trim(SubField([Class value],'-',2)) as To ,
        [Class value],
        Category
FROM InterVal_Table;

Data:
Load Country,
         Sales,
         Quantity,
         ApplyMap('map_class',Sales,'NA') as Sales_Class_Value,
         ApplyMap('map_class',Quantity,'NA') as Quantity_Class_Value,
         ApplyMap('map_category',Sales,'NA') as Sales_Category,
         ApplyMap('map_category',Quantity,'NA') as Quantity_Category
FROM Data_Table;