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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Vertical calculation on a horizontal dimension in pivot table

Hi All,

I am aggregating sales value on 3 dimensions in a pivot table(Zone,city,month(horizontal)).How do I calculate vertically on a horizontal dimension. For example, I want to calculate AvgQ1 as avg(Apr-15,May-15,Jun-15) as shown below.

Could you please help me on this? Thanks in advance.

 

Apr-15 May-15 Jun-15 Avg Q1 Jul-15 Aug-15 Sep-15 Avg Q2
NorthDelhi421410401411432451319401
Agra15771523164415811886192915551790
Jaipur180172180177194206209203
Lucknow107127149128126137154139
Chandigarh272279250267295294282290
Varanasi235217237230254278283272
Gurgaon187204212201224217244228
North Total29802932307329953412351230463323
1 Solution

Accepted Solutions
swuehl
MVP
MVP

I suggested to use only one expression, not creating a second one for the average.

The expression should branch into two evaluations for your details and the partial sum average based on Dimensionality() / SecondaryDimensionality() function.

You just need to enable partial sums for the correct dimensions.

View solution in original post

4 Replies
swuehl
MVP
MVP

You can create a field that groups your year month values into quarters in the script (e.g. using a master calendar), then use the Quarter field as additional horizontal dimension on top of the year month field.

Use a partial sum on presentation tab on the quarter field and an expression like

=If(SecondaryDimensionality() = 1,

     Sum(Sales) / Count(DISTINCT Month),

     Sum(Sales)

)

Not applicable
Author

Thank you Stefan for this idea.

After applying this logic , I am getting in the below format. But I wanted to display quarterly average next to month values as shown earlier.

sample2.PNG

swuehl
MVP
MVP

I suggested to use only one expression, not creating a second one for the average.

The expression should branch into two evaluations for your details and the partial sum average based on Dimensionality() / SecondaryDimensionality() function.

You just need to enable partial sums for the correct dimensions.

Not applicable
Author

Thank you Stefan for correcting my mistake. Now its working and I have got as below. Is it possible to not show quarterly dimension row and show partial sum label as 'Avg Q1'.sample3.PNG