Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
silvrwood
Contributor
Contributor

Transform table with header & subheader

I have an Excel file (table) in which the first row contains the headers and the second row contains the years as a subheader, like this:

Library# Visits# Visits# VisitsAvg SalaryAvg SalaryAvg SalaryCollection SizeCollection SizeCollection Size
200820092010200820092010200820092010
ABC50607010,00010,00012,000500050005200
DEF10001200150020,00021,00021,50010,00015,00016,000

I was able to get the year into its own column in Excel by transposing the data so the years were in columns, then creating a new worksheet with the library names and headers in their original positions, but with the year column from the transposed worksheet copied in, and then grouping the transposed data by year and individually transposing just the data for each year group into the new worksheet.  I hope that makes sense.  It was really confusing to work out, and it is confusing to remember how I did it.  At all odds, I ended up with something like this:

LibraryYear#VisitsAvg SalaryCollection Size
ABC20085010,0005000
ABC20096010,0005000
ABC20107012,0005200
DEF2008100020,00010,000
DEF2009120021,500015,000
DEF2010150021,50016,000

Can the transformation feature of QlikView do the same thing?  If so, how? 

3 Replies
swuehl
MVP
MVP

I don't think that the Qlik transformation can do this out of the box.

Have a look at

multi_header_pivot_import.qvw

Anil_Babu_Samineni

Can you check this way?

Sample:

CrossTable(FieldName, Data)

LOAD Library,

     [# Visits],

     [# Visits1],

     [# Visits2],

     [Avg Salary],

     [Avg Salary1],

     [Avg Salary2],

     [Collection Size],

     [Collection Size1],

     [Collection Size2]

FROM

[https://community.qlik.com/message/1561304]

(html, utf8, embedded labels, table is @1, filters(

Remove(Row, Pos(Top, 2))

));

Join

LOAD @1 as Year

FROM

[https://community.qlik.com/message/1561304]

(html, utf8, no labels, table is @1, filters(

Remove(Row, Pos(Top, 4)),

Remove(Row, Pos(Top, 3)),

Remove(Row, Pos(Top, 1)),

Rotate(left)

)) Where Len(@1)>0;

Final:

NoConcatenate

LOAD Library, FieldName as #Visits, Sum(Data) as Data, '#Visits' as Flag, Year Resident Sample Where WildMatch(FieldName,'#*')

Group By Library, FieldName, Year;

Concatenate

LOAD Library, FieldName as [Avg Salary], Sum(Data) as Data, 'Avg Salary' as Flag, Year Resident Sample Where WildMatch(FieldName,'Avg*')

Group By Library, FieldName, Year;

Concatenate

LOAD Library, FieldName as [Collection Size], Sum(Data) as Data, 'Collection Size' as Flag, Year Resident Sample Where WildMatch(FieldName,'Collection*')

Group By Library, FieldName, Year;

DROP Table Sample;

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
Anil_Babu_Samineni

Hello Mate, Can you see the thread.

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