Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikapple
Creator
Creator

changing column into row

Hi please find the dummy data

CRNOOUTSCOPEOUTAGEMINUTESIN NO
    
1234ONLINE3211234
1234DEGRADE 11234
2341ONLINE21ABC
2341DEGRADE32ABC
2341ONLINE43ABC
123456DEGRADE212312
123456DEGRADE322312
123456DEGRADE212312
123456ONLNE212312

 

 

The requirement is like this , I want to show IN NO as single(unique) so that it should not repeat again ,
     
Now I want the o/p as   

 

Now i want the O/P as

 

Anyone please help

 

CRNOOUTSCOPE(ONLINE Y)ONLINE MINUTESOUTSCOPE(DEGARDE Y)DEGRADE MINUTESIN NO
1234Y32N011234
2341Y21Y75ABC
123456Y21Y742312
Labels (1)
14 Replies
sunny_talwar

Yes that is because you have OUT_ID differences... may be you can combine the OUT_ID separated by comma?

Concat(DISTINCT OUT_ID, ', ') as OUT_ID
qlikapple
Creator
Creator
Author

I need the red rounded ones in one column

 

sunny_talwar

Give shot to have I mentioned above (Concat)... if that doesn't work... please provide a sample where we can see what you have and also provide details as to what you want to do with OUT_ID... meaning... if concatenating them okay?

qlikapple
Creator
Creator
Author

Hi Sunny,

i have done like this

 

LOAD * INLINE [
CRNO, OUTSCOPE,OUTID, OUTAGEMINUTES, IN NO
1234, ONLINE, ABC,32, 11234
1234, DEGRADE, !@C, , 11234
2341, ONLINE,asv, 21, ABC
2341, DEGRADE,qwe, 32, ABC
2341, DEGRADE,erd, 43, ABC
123456, DEGRADE,erd, 21, 2312
123456, DEGRADE,des, 32, 2312
123456, DEGRADE,dsc, 21, 2312
123456, ONLINE,ded, 21, 2312
]
;

FinalTable:
LOAD
Concat(DISTINCT OUTID, ', ') as OUT_ID,
CRNO,
[IN NO],
If(Sum(OUTAGEMINUTES) > 0, 'Y', 'N') as [OUTSCOPE(ONLINE Y)],
Sum(OUTAGEMINUTES) as [ONLINE MINUTES]
Resident Table
Where OUTSCOPE = 'ONLINE'
Group By CRNO, [IN NO];

Left Join (FinalTable)
LOAD
Concat(DISTINCT OUTID, ', ') as OUT_ID,
CRNO,
[IN NO],
If(Sum(OUTAGEMINUTES) > 0, 'Y', 'N') as [OUTSCOPE(DEGARDE Y)],
Sum(OUTAGEMINUTES) as [DEGARDE MINUTES]
Resident Table
Where OUTSCOPE = 'DEGRADE'
Group By CRNO, [IN NO];

DROP Table Table;

I am getting like this

 

sunny_talwar

How about something like this

Table:
LOAD * INLINE [
    CRNO, OUTSCOPE, OUTID, OUTAGEMINUTES, IN NO
    1234, ONLINE, ABC, 32, 11234
    1234, DEGRADE, !@C, , 11234
    2341, ONLINE, asv, 21, ABC
    2341, DEGRADE, qwe, 32, ABC
    2341, DEGRADE, erd, 43, ABC
    123456, DEGRADE, erd, 21, 2312
    123456, DEGRADE, des, 32, 2312
    123456, DEGRADE, dsc, 21, 2312
    123456, ONLINE, ded, 21, 2312
];

FinalTable:
LOAD CRNO,
	 [IN NO],
	 If(Sum(OUTAGEMINUTES) > 0, 'Y', 'N') as [OUTSCOPE(ONLINE Y)],
	 Sum(OUTAGEMINUTES) as [ONLINE MINUTES]
Resident Table
Where OUTSCOPE = 'ONLINE'
Group By CRNO, [IN NO];

Left Join (FinalTable)
LOAD CRNO,
	 [IN NO],
	 If(Sum(OUTAGEMINUTES) > 0, 'Y', 'N') as [OUTSCOPE(DEGARDE Y)],
	 Sum(OUTAGEMINUTES) as [DEGARDE MINUTES]
Resident Table
Where OUTSCOPE = 'DEGRADE'
Group By CRNO, [IN NO];

DROP Fields OUTSCOPE, OUTAGEMINUTES, [IN NO];

You will get your table like this

image.png

and yet have OUTID in your app in a separate table

image.png