# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
New Contributor

## Transpose Table

Hi, I am displaying a table looking like the following:

 Maturity Sales product1 Sales product2 Sales product3 1 year 5,913 8,133 -2,223 2 year 39,525 38,560 929 3 year 41,094 39,872 1,188 4 year 97,904 79,516 4,737 5 year 309,085 290,612 9,810 6 year 85,371 109,481 2,710

That I would like to transpose to look like this:

 Maturity 1 year 2 year 3 year 4 year 5 year 6 year Sales product1 5,913 39,525 41,094 97,904 309,085 85,371 Sales product2 8,133 38,560 39,872 79,516 290,612 109,481 Sales product3 -2,223 929 1,188 4,737 9,810 2,710

Any suggestions to do this please. Thanks very much.

15 Replies
Highlighted
Partner

## Re: Transpose Table

Create a pivot table:

as a dimension:

=ValueList('Sales Product1','Sales Product2','Sales Product3')

as a measure:

if(ValueList('Sales Product1','Sales Product2','Sales Product3')='Sales Product1', sum([Sales product1]),

if(ValueList('Sales Product1','Sales Product2','Sales Product3')='Sales Product2', sum([Sales product2]),

if(ValueList('Sales Product1','Sales Product2','Sales Product3')='Sales Product3', sum([Sales product3]))))

Maturity

RESULT:

Highlighted
New Contributor

## Re: Transpose Table

Thanks very much Omar. if i understood correctly, i go to charts, and select Pivot table

open it and fill it using the code you suggested by adding a dimension

Highlighted
Partner

Highlighted

## Re: Transpose Table

Script / Front end?

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Contributor III

## Re: Transpose Table

Hi,

You can achieve that by just converting your table to pivot table and switch column and rows. That's all you need

Highlighted
Partner

## Re: Transpose Table

Never thought this was  possible ! Thanks a lot !

Highlighted
Contributor

## Re: Transpose Table

Hi,

As Kaan rightly suggested, you can do it by simply creating a pivot chart and transposing your measures and Dimension.

But an alternate way to do this is in the script as well. PFA images for your reference.

Scripting :-

Output:-

Regards,

Saniya.

Highlighted
New Contributor

## Re: Transpose Table

Thanks Kaan. Can you please explain how to convert an existing table to pivot table ?

I have tried to create a new pivot table and flipped the columns into rows but did not get the right results. the reason being that the Sales Product columns don’t exist already in the tables, but I create them on the fly using formulas like

=sum(if([Product]='Product1', [Sales])) for Sales product1 column.

=sum(if([Product]='Product2', [Sales])) for Sales product2 column

=sum(if([Product]='Product3', [Sales])) for Sales product3 column

Highlighted
Valued Contributor

## Re: Transpose Table

Hi,

You can just drag a Pivot Table over a Table as select Convert if you want to convert it but you may have to review the default design and may not get exactly what you want right away.

To create from scratch just try something simpler:

Dimension: Product

Measure: Sales and select Sum

Then Add Data (Column) and select Year

Then, if you want, you can restrict Sales to specific products by editing the Measure and changing it from

Sum(Sales)

to

Sum({<Product={"Product1","Product2","Product3"}>} Sales)

I hope this helps,

Luis