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

1 Solution

Accepted Solutions
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

View solution in original post

13 Replies
sunny_talwar

Not sure, but may be this is what you are looking for

Sum({<Date = {"$(=Date(Max(Date), 'MM.DD.YYYY'))"}>} [Unit Cost]*Quantity)

thanhphongle
Creator II
Creator II
Author

In the expression QV says "Expression OK" but it still returns me "Error: E..."

My proper function looks different from the example. I exactly paste in the fields I need. Can you have a look on my real function?

=Sum({<contract_begin = {"$(=contract_begin(Max(contract_begin), 'MM.DD.YYYY'))"}>} (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)))))

sunny_talwar

Hahahaha my bad I didn't differentiate between your date and date() function... try this

=Sum({<contract_begin = {"$(=Date(Max(contract_begin), 'MM.DD.YYYY'))"}>} (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)))))

thanhphongle
Creator II
Creator II
Author

I still have the same error See here Error.png

thanhphongle
Creator II
Creator II
Author

The object which returns Error: E... is an Textobject

sunny_talwar

Does this expression work without the set analysis part? May be there is something else which is wrong and set analysis works fine?

thanhphongle
Creator II
Creator II
Author

I dont know, actually I dont have any idea. Ive thought that set analysis would be the right way.

sunny_talwar

Would you be able to share your qvw?

thanhphongle
Creator II
Creator II
Author

I just attached the qv file