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: 
Not applicable

How to pivot the data of rows into columns

Hi All,

I have a table where data will be like

2014-06-16_1337.png

But i want my data to be like

Location Num      Week       Sales

3013                  week1         2448

3013                  week2         2513

3020                  week1         3957

3020                  week2          3673         

And so, on .I have attached my QVW. Can someone help me with any suggestions ?

Thanks         

2 Solutions

Accepted Solutions
gmoraleswit
Partner - Creator II
Partner - Creator II

Please see attached file

View solution in original post

gmoraleswit
Partner - Creator II
Partner - Creator II

Store the calendar table in a qvd:

store Calendar into Calendar.qvd;

DROP Table Calendar;

Calendar:

LOAD *,

  num(FiscalYearId & num(FiscalMonthOfYearId,'00') & num(FiscalWeekOfMonthId,'00')) as key

FROM

Calendar.qvd

(qvd);

qvd.JPG.jpg

View solution in original post

12 Replies
gmoraleswit
Partner - Creator II
Partner - Creator II

Not applicable
Author

What you need is a dimension "week"  that has "week1" and "week2" as fields

Then make your pivot table with "location num" and "week" as dimensions, and then use "sales" as your expression.

Or you could use a cross table, there are just different options

Not applicable
Author

Find the attached document

Not applicable
Author

Just drag the Week column from the column section to the rows. Hope it helps you.

Pivot.png

Not applicable
Author

Can you try something like this in your load script.

LOAD D AS LocationNum, 

    BR AS Week1,

      BS  AS Week2,

      BT AS Week3,

      BU  AS Week4,

      BV  AS Week5,

      IF (BR = Week1,'1',

     IF (BS=Week2,'2',

     IF (BT = Week3, '3',

     IF (BU = Week4,'4',

     IF (BV = Week5,'5'))))) as week

from xyz;

Not applicable
Author

Try

LOAD D AS LocationNum, 

    BR AS Week1,

      BS  AS Week2,

      BT AS Week3,

      BU  AS Week4,

      BV  AS Week5,

      IF (BR = 'Week1','1',

     IF (BS='Week2','2',

     IF (BT = 'Week3', '3',

     IF (BU = 'Week4','4',

     IF (BV = 'Week5','5'))))) as week

Not applicable
Author

post your qvw here

dmac1971
Creator III
Creator III

Yep drag and drop is all that is needed here.

lironbaram
Partner - Master III
Partner - Master III

hi

have a look at the attach example