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

sum(TOTAL cost) of the latest date

Hello Community

this is my table

DateUnit CostQuantity
01.01.2016105
01.01.2016103
01.04.2016504
01.10.20161003
01.10.2016105
01.10.20162002
01.10.20161504

How can I get the total cost sum([Unit Cost]*Quantity) for the last date 01.10.2016 ?

QV should return: 100*3 + 10*5 + 200*2 + 150*4 = 1350

13 Replies
sunny_talwar

You issue is that you have use Sum(....Sum(... function.... you need to add Aggr() between the two sum function

Sum(Aggr(Sum(.....

But since I am not entirely sure what your goal is, it is difficult to say. What is the numerical output you expect to see within your sample?

thanhphongle
Creator II
Creator II
Author

if you add contract_begin as a listbox you ll see that 01.10.2017 is the latest date.

the main expression is: (1-(1/(sum(cost_acquisition*cost_rate_reg_perc*(contract_term_reg+lm_term)))*sum(cost_acquisition*cost_rate_reg_csc_perc*(contract_term_reg+lm_term))))


the function should return me the calculation of the main expression referring to the latest date 01.10.2017

sunny_talwar

It repeats the same number for each of your date

Capture.PNG

But this is sort of working

=(1-(1/(sum({<contract_begin = {"$(=Date(Max(contract_begin), 'DD.MM.YYYY'))"}>} cost_acquisition*cost_rate_reg_perc*(contract_term_reg)))*sum({<contract_begin = {"$(=Date(Max(contract_begin), 'DD.MM.YYYY'))"}>} cost_acquisition*cost_rate_reg_csc_perc*(contract_term_reg))))

Your date format is not MM.DD.YYYY, it is DD.MM.YYYY

thanhphongle
Creator II
Creator II
Author

Oh my god, you r defenitly the best !! It works. Thank you very much !!!