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

Pivot table with grouping

Hi all,

hope you can help me on this issue:

my raw data contains 3 data sets:

iddate1date2classamount
101.01.201205.01.2012a1
202.01.201205.01.2012b2
303.01.201205.01.2012b3

As you can see

  • set 1 is overdue 4 days (05.01.2012 - 01.01.2012 = 4 days)
  • set 2 is overdue 3 days (05.01.2012 - 01.01.2012 = 3 days)
  • set 3 is overdue 2 days (05.01.2012 - 01.01.2012 = 2 days).

Now I would like to present the sum of amounts in a pivot table grouped by class like this:

classtotaloverdue <= 2 daysoverdue >= 4 days
a101
b530

My pivot table in QlikView contains the dimension "class" and the following 3 expressions:

  • sum(amount) labeled "total"
  • if (date2-date1 <= 2, sum(amount), 0) labeled "overdue <= 2 days"
  • if (date2-date1 >= 4, sum(amount), 0) labeled "overdue >= 4 days"

With these expressions my pivot table does not look like expected but it looks like this:

classtotaloverdue <= 2 daysoverdue >= 4 days
a101
b500

Do you know what I did wrong?

Thanks in advance for your help.

Best regards

Dan

P.S. See also my QVW attached.



6 Replies
SunilChauhan
Champion
Champion

see attched file

use date2-date1 as difference in script

hope this helps

Sunil Chauhan
sujeetsingh
Master III
Master III

Your pivot table is 100% correct.

When you write if(date2-date2<=2,sum(Amount),0)

Here the date2-date1 is grouped on the dimension you are using that is Class

For Class b the Date2-date1 has two values as 2 and 3 , now for the whole class it is added as 2+3=5 which is not <=2 hence it represents 0

Not applicable
Author

My problem is that the users should have the possibility to change the value for date2 with a calender object in the GUI. Then the pivot table should be re-calculated.

That is why, I think I could not calculate the difference in the load script.

Not applicable
Author

Ok, I see. Is it possible to re-write my expression, that only the amount of data set 3 is taken into account for class b (not the whole sum)?

Not applicable
Author

Perhaps there is a way to re-calculate the difference when the user changes date2 in the calender object (e.g. with a trigger or something else)?

Not applicable
Author

Please find attached my test.qvw using a calendar object for date2.