Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Shahzad_Ahsan
Creator III
Creator III

How to make calculation in pivot table

Hi

I have pivot table like below in qlik sense. where "Name" is as dimension and Month-Year as Column and the numbers are in measures.

NameJan-19Feb-19Mar-19Apr-19
A100503665
B20021572574
C3006954885
D4002477798

 

I need to calculate the below data on behalf of above table.

Here, the condition goes like this, Every column is divided by "Apr-19" column

Eg: 100/65=1.54

CategoryJan-19Feb-19Mar-19Apr-19
11.540.770.551
22.7029.150.341
33.538.180.561
44.082.520.791

 

Problem: when I am dividing Jan-19/Apr-19,  it always returns 0. 

Labels (1)
19 Replies
sunny_talwar

Would you be able to show a sample where you are trying it out? Sample shared with us doesn't seem to have Jan-2018?

Shahzad_Ahsan
Creator III
Creator III
Author

Hi @sunny_talwar 

Please find attached sample qvf.

Check "Sheet 2"

Jan-2019 is showing data but Jan-2018 is showing 0. I need the value for Jan-2018 as well.  

sunny_talwar

Here is your expression for Jan-2018
Sum(TOTAL <Bkt, Dpd> {<[Month-Year] = {'1/1/2018'}>} Amount)

 

Now for this to work, you would expect Month-Year to have a value of 1/1/2018, right? or do you imagine that Qlik will create them from somewhere? These are the Month-Year available and I am not seeing 1/1/2018

image.png

Shahzad_Ahsan
Creator III
Creator III
Author

Hi Sunny
Please check the field "Month" . that contains all data from 2017.


sunny_talwar

Change your load to this

Table2:
LOAD
Month,
date(date#(Month, 'MMM-YYYY')) as [Month-Year]
Resident Table1;

 

and then check Jan-2018

Shahzad_Ahsan
Creator III
Creator III
Author

I got it what you are trying to show but I want to show only last 1 year data on the pivot table. that means from Mar-2018 to Mar-2019 

At the same time want to pick Jan-2018 value also

Suppose Jan-19 Amount is 200 and Jan-18 Amount is 50 so I need the result like this.

I dont want to show Jan-18 as column

 Mar-18Apr-18May-18Jun-18Jul-18Aug-18Sep-18Oct-18Nov-18Dec-18Jan-19Feb-19Mar-19
Jan-19200200200200200200200200200200200200200
Jan-1850505050505050505050505050
sunny_talwar

Don't know what the goal is, but try this

Sum(TOTAL{<[Month] = {"Jan-2018"}>} Amount)

Shahzad_Ahsan
Creator III
Creator III
Author

Hi Sunny

Thanks for your support. This is what I needed. It looks strange what I am trying to achieve.

But I have last question related to this.

How can I get previous columns

Suppose If we are calculating for Jan-2019

Value for Jan-19 = Jan-19/Dec-18+Nov-18+Oct-18

sunny_talwar

Something like this
Sum(Amount)/RangeSum(Before(Sum(Amount), 1, 3))

or something similar based on your chart and sort order of MonthYear field

Shahzad_Ahsan
Creator III
Creator III
Author

Hi Sunny
Thank you for all the support.
This is working fine
Highly Appreciated !!