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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
katetsan
Creator
Creator

Create a column in Pivot Table

Hi Experts,

I'm wondering if there's possible to create a column in pivot table?

The format is like below, Month is as the dimension in the pivot table, and I would like to create extra column called 'MoM'.

Is there any way to make this happen?

ItemJanFebMarMoM
A10011090-20
B150160130-30
C809060-30
D506010040

Thanks a lot

4 Replies
devarasu07
Master II
Master II

Hi,

try like this

Dim:

Item

ValueList('Jan','Feb','Mar','MoM')

Expression

if(ValueList('Jan','Feb','Mar','MoM')<>'MoM',sum({$<Month={'Mar'}>}Amt),sum({$<Month={'Mar'}>}Amt)-sum({$<Month={'Feb'}>}Amt))

Capture.JPG

P.S: based on you Calendar data you can change the Month/Date value in above expression.

Thanks,Deva

Sergey_Shuklin
Specialist
Specialist

Hello, Kate!

You can also use Pick() function, but first you need to improve your script with wthis load:

Load * inline

[dim

1

2];

after that create a pivot table with two dimensions:

Item

and

Pick(dim,month_field,'MoM')

As expression use this:

Pick(dim,sum(val),sum({<cur_month>}val)-sum({<prev_month>}val))

pradosh_thakur
Master II
Master II

hi

as per your requirement and if i understood it correctly you want to create a dynamic/extra column that will show the subtraction of two column march and feb in this case which can be pre populated or else calculated

1:create column MOM

2: in expression type column name1 within  [ ] - column name 2 within [ ]

  something like [column1]-[column2] or [Mar] - [Feb]

share the app if it doesn't work for you.

regards

Pradosh

Learning never stops.
katetsan
Creator
Creator
Author

Hi Devarasu,

Thanks for your reply.

What if there is more than three months, is it possible to use the field name like "Month" instead of individual month (such as Jan, Feb, and Mar)?

Thanks