Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pivot table calculation

Hello,

Please see attached XLS file for an example I would like to build in QV. Creating the "base" pivot table is easy but getting stuck in trying to add blue shaded column and rows.

Any idea how to achieve this?

Thanks you!

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

The 'All Types' lines that you want at the bottom cannot be created without a change in the data model. So that's why you should add a small table in the load script:

     Load RecNo()-1 as IsTotal Autogenerate 2;

Then I use this table together with the Dim1 to create the 4 dimensional values that you want (1,2,3,All types) by using a calculated dimension:

     =Aggr(Only(If(IsTotal,'All Types',Dim1)),Dim1,IsTotal)

HIC

Image1.png

View solution in original post

6 Replies
hic
Former Employee
Former Employee

The rightmost column can be created using a formula like

     If(Dimensionality()=2,

          Count(X)/Count(total <Dim1> X),

          Count(X)/Count(total X))

But the bottom rows are trickier. For that you need to change the data model.

HIC

hic
Former Employee
Former Employee

I just realized that you can get the bottom rows doing the following:

Add the following Load statement to your script:

     Load RecNo()-1 as IsTotal Autogenerate 2;

Then you can define your Dim1 in the pivot as (Calculated Dimension):

     =Aggr(Only(If(IsTotal,'All Types',Dim1)),Dim1,IsTotal)

HIC

Not applicable
Author

Hi,

Is a specific chart but I do it using 2 charts (Pivot Table and Straight Table), and change origina data see XLS file.

I hope it will usefull for you. Regards.

Not applicable
Author

Hi Henric,

Thank you for your response. Not quite sure I am following your train of thought. Can you please explain your approach?

Marko

Not applicable
Author

Hi Oswaldo,

Thanks for your response. I was thinking of adding straight table but would love to fulfil business requirement, if possible, to have it all displayed in the pivot chart. This will be my last resort.

Marko

hic
Former Employee
Former Employee

The 'All Types' lines that you want at the bottom cannot be created without a change in the data model. So that's why you should add a small table in the load script:

     Load RecNo()-1 as IsTotal Autogenerate 2;

Then I use this table together with the Dim1 to create the 4 dimensional values that you want (1,2,3,All types) by using a calculated dimension:

     =Aggr(Only(If(IsTotal,'All Types',Dim1)),Dim1,IsTotal)

HIC

Image1.png