Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Kohli
Creator II
Creator II

divide the single table into 2 tables based on Field values.

I have table like

Table1:

Flight, Sector,   Pax,     Fare

123,   djhdww,    1,       1200

123,   bdwehj,     1,       1500

123,   jasadhj,   N/A,      2000

124,   sgshgs,    N/A,     5000

output tables:

Connected:

Flight, Sector,   Pax,     Fare

123,   djhdww,    1,       1200

123,   bdwehj,     1,       1500



Direct Flight:

Flight, Sector,   Pax,     Fare

123,   jasadhj,   N/A,      2000

124,   sgshgs,    N/A,     5000

5 Replies
kfoudhaily
Partner - Creator III
Partner - Creator III

do you know in advance how many values you can have in the field "flight"

QlikView Qlik Sense consultant
dplr-rn
Partner - Master III
Partner - Master III

can i ask why you want to split the tables? why not just put a flag saying direct or not?

mdmukramali
Specialist III
Specialist III

Hi,

U can add if condition in the same Table like

If(pax=1,'Connected','Direct Flight') as FlightType



if you have some other requirement than u can try something like below:


Table1:

LOAD * Inline

[

Flight,Sector,Pax,Fare

123,djhdww,1,1200

123,bdwehj,1,1500

123,jasadhj,N/A,2000

124,sgshgs,N/A,5000

]

;

NoConcatenate

Connected:

LOAD *

Resident Table1

Where Pax=1;

NoConcatenate

Direct_Flight:

LOAD *

Resident Table1

Where Pax<>1;

DROP Table Table1;

kfoudhaily
Partner - Creator III
Partner - Creator III

table: // your table loaded inline

LOAD * INLINE [

Flight, Sector,   Pax,     Fare

123,   djhdww,    1,       1200

123,   bdwehj,     1,       1500

123,   jasadhj,   N/A,      2000

124,   sgshgs,    N/A,     5000

];

temp: //a temp table to get all distinct values of field "Flight"

load Distinct

Flight as val

Resident table Order by Flight;

for i=1 to NoOfRows('temp') // count to the number of rows of last table

LET value = peek('val', $(i), 'temp');

result_table$(i):

LOAD * INLINE [

key, Flight

$(i), $(value)

];

left join

load *

resident table;

store result_table$(i) into result_table$(i).qvd (qvd);

drop table result_table$(i);

NEXT i;

drop tables table,temp;

QlikView Qlik Sense consultant
Anil_Babu_Samineni

You can restricted using Where Condition from Each field?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful