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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
BI_Dev
Creator II
Creator II

Crosstable multiple columns

Hi - I have table as below.

 

IDStage1StartStage2StartStage1EndStage2EndStage1Stage2
ABC10/5/202110/30/202110/15/20219/15/2021yn
BCD1/9/202110/9/202110/30/202110/5/2021ny

 

I want to just keep 3 columns as below.

 

IDStageStage_Y_NStartEnd
ABCStage1y10/5/202110/15/2021
ABCStage2n10/30/20219/15/2021
BCDStage1n1/9/202110/30/2021
BCDStage2y10/9/202110/5/2021

 

Is this doable ? Thank you much.

Labels (1)
1 Solution

Accepted Solutions
Saravanan_Desingh
MVP
MVP

Try this,

tab1:
LOAD * INLINE [
    ID, Stage1Start, Stage2Start, Stage1End, Stage2End, Stage1, Stage2
    ABC, 10/5/2021, 10/30/2021, 10/15/2021, 9/15/2021, y, n
    BCD, 1/9/2021, 10/9/2021, 10/30/2021, 10/5/2021, n, y
];

tab2:
CrossTable(Stage, Stage_Y_N)
LOAD ID, Stage1, Stage2
Resident tab1;

tab3:
CrossTable(Stage, Start)
LOAD ID, Stage1Start As Stage1, Stage2Start As Stage2
Resident tab1;

tab4:
CrossTable(Stage, End)
LOAD ID, Stage1End As Stage1, Stage2End As Stage2
Resident tab1;

Left Join(tab2)
LOAD * Resident tab3;

Left Join(tab2)
LOAD * Resident tab4;

Drop Table tab1, tab3, tab4;

commQV12.PNG

View solution in original post

1 Reply
Saravanan_Desingh
MVP
MVP

Try this,

tab1:
LOAD * INLINE [
    ID, Stage1Start, Stage2Start, Stage1End, Stage2End, Stage1, Stage2
    ABC, 10/5/2021, 10/30/2021, 10/15/2021, 9/15/2021, y, n
    BCD, 1/9/2021, 10/9/2021, 10/30/2021, 10/5/2021, n, y
];

tab2:
CrossTable(Stage, Stage_Y_N)
LOAD ID, Stage1, Stage2
Resident tab1;

tab3:
CrossTable(Stage, Start)
LOAD ID, Stage1Start As Stage1, Stage2Start As Stage2
Resident tab1;

tab4:
CrossTable(Stage, End)
LOAD ID, Stage1End As Stage1, Stage2End As Stage2
Resident tab1;

Left Join(tab2)
LOAD * Resident tab3;

Left Join(tab2)
LOAD * Resident tab4;

Drop Table tab1, tab3, tab4;

commQV12.PNG