Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Condition with priority order

hi,

I would like to create a column who will look for the sames id's if a condition is respected.

Then i would like to display for the sames id's the result of the "condition1" if condition1= T,

then display  for the sames id's the result of the "condition2" if condition1=F and condition2=T,

...

Exemple :

ID    condition 1    condition 2    condition 3    temp_Result    ColumnToCreate

1            1                    0                    1                  good                         good

1            0                    1                    0                  oke                           good

1            0                    0                    1                  middle                      good

2            0                    1                    1                 oke                              oke

3            0                    0                    1                 middle                         oke

3            0                    1                    1                 oke                              oke  

So i have an order of priority like : condition 1 > 2 > 3

So if i have for one id the condition 1 and 3 i would like to keep the 1 for all rows of this id,

the condition 2 and 3 i would like to keep just the 2 for all rows of this id.

I work with Qlik sense.

I have tried to use the function 'peek' but i can't find a solution to this problem.

Je travaille sur Qlik sense. J'ai essayé d'utiliser la fonction 'peek' mais je ne trouve pas de solution.

Thanks in advance for your help,

Amin.

1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:

LOAD *,

If(condition1 = 1, Dual('good', 1),

If(condition2 = 1, Dual('oke', 2), Dual('middle', 3))) as tempResult;

LOAD * INLINE [

    ID, condition1, condition2, condition3

    1, 1, 0, 1

    1, 0, 1, 0

    1, 0, 0, 1

    2, 0, 1, 1

    3, 0, 0, 1

    3, 0, 1, 1

];


Left Join (Table)

LOAD ID,

MinString(tempResult) as ColumnToCreate

Resident Table

Group By ID;

View solution in original post

5 Replies
Anil_Babu_Samineni

temp_Result is okay but what is the last column? Can you describe little

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Anonymous
Not applicable
Author

In the last column i would like to have ONE result per id.

for id 4 if i have 3 row with 'middle' 'oke' and  'good' i would like to display 'good' in the 3 rows.

Because i have an order of priority like : condition 1 > 2 > 3

               so good> oke> middle

I hope that it is more clear now.

sunny_talwar

Try this

Table:

LOAD *,

If(condition1 = 1, Dual('good', 1),

If(condition2 = 1, Dual('oke', 2), Dual('middle', 3))) as tempResult;

LOAD * INLINE [

    ID, condition1, condition2, condition3

    1, 1, 0, 1

    1, 0, 1, 0

    1, 0, 0, 1

    2, 0, 1, 1

    3, 0, 0, 1

    3, 0, 1, 1

];


Left Join (Table)

LOAD ID,

MinString(tempResult) as ColumnToCreate

Resident Table

Group By ID;

Anonymous
Not applicable
Author

That was exactly what i was looking for.

thanks a lot.

Anonymous
Not applicable
Author

Love your solution, first the dual to create de degree of priority, then the minstring function. And last group it by id so i will have one result for each id.

You helped me a lot there, ty