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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Kohli
Creator II
Creator II

how to appends the two fields into one.

I have table like 

Gender, Sales, Gender, Sales

Male,100, Female, 200

Male, 300, Female, 200

male,100, Female, 400

I want output like

Gender, Sales

Male, 100

Male, 300

Male, 100

Femlae, 200

Female, 200

Female, 400

Labels (1)
3 Replies
petter
Partner - Champion III
Partner - Champion III

This is a way to do it:

INDATA:
LOAD * INLINE [
Gender, Sales, Gender2, Sales2
Male,100, Female, 200
Male, 300, Female, 200
male,100, Female, 400
];

DATA:
LOAD
  If( IterNo()=1 , Gender , Gender2 ) AS Gender,
  If( IterNo()=1 , Sales , Sales2 ) AS Sales
RESIDENT
  INDATA
WHILE
  IterNo()<=2;

DROP TABLE INDATA;

petter
Partner - Champion III
Partner - Champion III

Reading from a CSV-file it would be as simple as this:

 LOAD
  If( IterNo()=1 , 'Male' , 'Female' ) AS Gender,
  If( IterNo()=1 , @2 , @4 ) AS Sales
FROM
  "INDATA.TXT.txt" (txt, no labels, header is 1 line)
WHILE
  IterNo()<=2;

passionate
Specialist
Specialist

You will surely get a solution for this but, in first place how did you get that table structure because there should be some identifier for each row i.e. male or female like a primary key or name.