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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Adding pivot table dimentions together

Hi,

I cant seem to do something I thought would be quite simple.

I want to do caluclations on 2 coulmns within a pivot table

MonthYear20112012
Jun 8041
May 11852
Feb 1941
Aug 4818
Nov 44-
Jul 4447
Apr 2366
Oct 60-
Mar 1458
Dec 34-
Sep 57-
Jan 738

I would like a column at the end that can work a percentage out. This is quite straightforward in excel, but cant work out how to do it in QlikView

Any help would be great.

I currently have 2 dimentions, Month and Year, and 1 expression which is COUNT(ClientID)

Cheers

1 Solution

Accepted Solutions
whiteline
Master II
Master II

Add the lines that I suggested above.

Replace 'SomeTable' with your table name from where you copied the string to your post.

View solution in original post

6 Replies
Anonymous
Not applicable
Author

There are a few ways to do this, you can simply write "Column(2)/Column(3)" to divide the second column with the third, this is a bit unstable if you start moving columns around or in this case you add more years...

You can also use Set Analysis to compare different values with each other.

 

COUNT({$<Year={$(=Max(Year)-1)}>} ClientID) /COUNT({$<Year={$(=Max(Year))}>} ClientID)

This would divide 2011 with 2012  (if you had more years then you would compare the max value of year with the previous year ie. 2012 - 1 = 2011 or if you selected 2011 then it would be 2011-1 = 2010). Check out the help or

comunity for more info on Set Analysis.

whiteline
Master II
Master II

I'll show the secret:

Headers:

LOAD distinct

     Year

     Year as YearHeader

Resident SomeTable;

Concatenate(Headers)

LOAD

     'Percentage' as YearHeader

Autogenerate (1);

Then use  YearHeader instead of Year as dimension.

Correct your expression so that for  YearHeader = 'Percentage' it returns the desired percentage.

Not applicable
Author

Hi,

Would you be able to attach an example. I've tried doing it and read help files, but if I put another expression in I get 2 per year and the nex expression just has a '-'.

Cheers

whiteline
Master II
Master II

Did you modify the script and create YearHeader ?

Not applicable
Author

Hi,

You posted that as I was posting mine.

However the script has confused me a bit as I already a bit of manipulating my data in the script.

The Year is taken from a date so in my load script i do:

TEXT

(date(RTTDate, 'YYYY')) as Year

Cheers

whiteline
Master II
Master II

Add the lines that I suggested above.

Replace 'SomeTable' with your table name from where you copied the string to your post.