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: 
upaliwije
Creator II
Creator II

Sum of Amount

I have following data in my pivot table

IDNo    Days_left     Total Days   Amount     dept         calculation

1          10                    365               1000          x          amount*days_left/TotaL_days =27

2          30                    365                2500         x

3          40                    365                4000         y

4         100                   365               10000        y

5          120                  365                5000         y

When I cal calculate the above it works fine against individual rows but when I group  by Dept  Amount shown under calculation is zero

what is the expression I should write please

7 Replies
vijay_iitkgp
Partner - Specialist
Partner - Specialist

Hi , You can use Sum(Amount*DaysLeft/Total_days). It will give you correct result.

JonnyPoole
Former Employee
Former Employee

i would start by putting in some aggregation functions so that it knows how to aggregate the numbers:

like this:   sum( amount * days) / sum(Total Days)

See if that works first.

maxgro
MVP
MVP

maybe

sum(Amount*Days_left)/sum([Total Days] )

upaliwije
Creator II
Creator II
Author

Thanks all

But none of the expression works even for a single row

but my following expression work for individual rows

=(AMOUNT)*(DAYS_LEFT/TOTAL_DAYS)

JonnyPoole
Former Employee
Former Employee

how about this ?  i just changed the exact syntax to match the field names in your example above


sum([AMOUNT]*[DAYS_LEFT]) / sum ([TOTAL_DAYS])

upaliwije
Creator II
Creator II
Author

that is also not working even against individual rows

JonnyPoole
Former Employee
Former Employee

Can you share the QVW ?  I'm sure its a small tweak to the expression but i don't want to guess..