Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Use condition inside Sum()

I want to display the savings value corresponding to a particular date using an expression.

I tried using the below expression but it's not working.

sum(

if(

date(TimeStamp#([processed_date],'YYYY-MM-DD hh:mm:ss.s'),'DD/MM/YYYY')))= date(TimeStamp#('2017-01-02 00:00:00.0','YYYY-MM-DD hh:mm:ss.s'),'DD/MM/YYYY'))),

[Savings],

0

))

can anyone help on this pls?

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

Hi Faris,

try this

=sum(
if(
date(TimeStamp#([processed_date],'YYYY-MM-DD hh:mm:ss.f'),'DD/MM/YYYY')
= date(TimeStamp#('2017-01-02 00:00:00.0','YYYY-MM-DD hh:mm:ss.f'),'DD/MM/YYYY'),
[Savings]
,
0
))

Regards,

Antonio

View solution in original post

2 Replies
stigchel
Partner - Master
Partner - Master

If the time of the particular date is of no interest, I would suggest to floor (removing the time portion) the date before comparing. See also

Rounding Errors

antoniotiman
Master III
Master III

Hi Faris,

try this

=sum(
if(
date(TimeStamp#([processed_date],'YYYY-MM-DD hh:mm:ss.f'),'DD/MM/YYYY')
= date(TimeStamp#('2017-01-02 00:00:00.0','YYYY-MM-DD hh:mm:ss.f'),'DD/MM/YYYY'),
[Savings]
,
0
))

Regards,

Antonio