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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
waleeed_mahmood
Creator
Creator

Splitting IDs and assign numbers to first ID

Hello,

I hope you are doing well.

My question is as follows:

As shown below, i have a table (Source Table) that i have to load into QS. However, the ID column has multiple IDs in it and we want to split that. However, if i split it, the targets also get split and we have duplicates. Is there a way to have the source table where the targets/actuals are only assign to 1 ID (doesnt matter which one) and the rest are 0.

Source Table:

CustomerIDTargetsActuals
C1C1_ID1,C1_ID2,C1_ID325000004500000
C2C2_ID1,C2_ID2,C2_ID3321000423000

 

Result Table:

CustomerIDTargetsActuals
C1C1_ID125000004500000
C1C1_ID200
C1C1_ID300
C2C2_ID1321000423000
C2C2_ID200
C2C2_ID300

 

Please ask if you have any questions.

Thank you for your help. 

Labels (2)
1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:
LOAD Customer,
	 SubField(ID, ',') as ID,
	 If(AutoNumber(RowNo(), Customer) = 1, Targets, 0) as Targets,
	 If(AutoNumber(RowNo(), Customer) = 1, Actuals, 0) as Actuals;
LOAD * INLINE [
    Customer, ID, Targets, Actuals
    C1, "C1_ID1,C1_ID2,C1_ID3", 2500000, 4500000
    C2, "C2_ID1,C2_ID2,C2_ID3", 321000, 423000
];

View solution in original post

2 Replies
sunny_talwar

Try this

Table:
LOAD Customer,
	 SubField(ID, ',') as ID,
	 If(AutoNumber(RowNo(), Customer) = 1, Targets, 0) as Targets,
	 If(AutoNumber(RowNo(), Customer) = 1, Actuals, 0) as Actuals;
LOAD * INLINE [
    Customer, ID, Targets, Actuals
    C1, "C1_ID1,C1_ID2,C1_ID3", 2500000, 4500000
    C2, "C2_ID1,C2_ID2,C2_ID3", 321000, 423000
];
waleeed_mahmood
Creator
Creator
Author

Thank you @sunny_talwar