Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
QlikTonic
Contributor III
Contributor III

Help please

Hi evrybody,

 

I need your help please ! I am not a developer but i am very motivated to learn,

I have 2 tables, one for order and one for orderdetails.

Order :
OrderNum
250400
250410
250420
250430

  

Detail order :   
OrderNumProductQuantityPrice
250400123110
25040065058
250400210314
250410137910
250410123710
250410159510
250410110917
250410201412
25042065088
2504202101014
250430137612
250430123310
250430159815

if in an order i have the product 650 i want to add for each line of the concern order : Contain650

it shoud be

Order : 
OrderNumContain650
2504001
2504100
2504201
250430

0

 

to try to do that i wrote :

left join(Order) 
load *,  
if(  
Product='650', 1,0) as Contain650;
   
Load  
OrderNum  
Product   
resident Detail Order 

 

 but the result is wrong , i have :

Order : 
OrderNumContain650
2504000
2504001
2504100
2504200
2504201
2504300

 

i have 0 and 1 for each order, i don't understand why, can someone help me please ?

Many thanks

C.

9 Replies
Sazabi
Creator
Creator

This is because the original table is broken out by Product.
Just because you have omitted Product in the final table, it will not do a group by.

You will be fine if you leave Product column in final resulting in-memory table.

In the Qlik front-end, it will do the group by for you when you create a table of OrderNum | sum(Contains650)

Regards,

S

QlikTonic
Contributor III
Contributor III
Author

thanks for your answer, but when i write load *, it includes Product, no ?

left join(Order) 
load *,  
if(  
Product='650', 1,0) as Contain650;
   
Load  
OrderNum  
Product   
resident Detail Order
left join(Order) 
load *,  
if(  
Product='650', 1,0) as Contain650;
   
Load  
OrderNum  
Product   
resident Detail Order
Sazabi
Creator
Creator

Is this table you have in the data model or a table created in a sheet?

Order : 
OrderNumContain650
2504000
2504001
2504100
2504200
2504201
2504300

 

If you have OrderNum as a dimension, and sum(Contain650) as a measure, you will have your intended result of 

Order : 
OrderNumContain650
2504001
2504100
2504201
250430

0

 

QlikTonic
Contributor III
Contributor III
Author

In fact my objective is to have 1 in my order table  if i have a product 650 in an order detail

 

 

Sazabi
Creator
Creator

If you add this to the script, your in-memory fact table should produce your wanted results:

Load

OrderNum,

sum(Contain650)

Resident Order

group by OrderNum;

 

 

The only reason you see duplicates in your current result set is because a join is a Cartesian product, and the join conditions are a little ambiguous 🙂

 

Regards,

 

S

QlikTonic
Contributor III
Contributor III
Author

i had created the case in excel.

in reality :

qlikcommunauty.PNG

if i have the prestation ct21.1210 i want to change the admission type from AMBU to CONS... i have two times the lines and always keep my ambu admission type

 

QlikTonic
Contributor III
Contributor III
Author

this is like duplicated... the old and the new 😞

Sazabi
Creator
Creator

I see, I see.

 

In this case you don't need to do a join at all. You want to modify the fact table based on condition Prestation = 'CT21.1210'

 

If you just do:

Load 

if(Prestation = 'CT21.1210', 'CONS', Type admission) as Type admission,

your other stuff

RESIDENT TableName

 

you will change AMBU to CONS if Prestation is CT21.1210.

No duplicates 🙂 🙂 🙂 No joins needed

QlikTonic
Contributor III
Contributor III
Author

 

 

 

 

 

I have always en double my informations, i wrote :

left join(Sejour_serviceTemp)

 

Load
DossierNum,
PrestaNum as PrestaL
resident Prestation
order by DossierNum;

 

and

 

Sejour_Service:
LOAD *,
if(
PrestaL='CT21.1210', 'CONS',
) as ADMCode,
Resident Sejour_serviceTemp;

drop table Sejour_serviceTemp;

DROP FIELDS PrestaL;

 

 

😞