Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

if-condition in expression

 

Hi all!

I need some help with conditioning a calculation. I want to know how many distinct articles that have a delivery time greater than 2 days. My delivery time is formatted as “D + hh:mm:ss” and works well in other expressions.

Writing my expression as “if(time >=’2 + 00:00:00’, Count(DISTINCT(article),0)” does not work. It only shows the zero-value. What am I doing wrong?

Thank you!

 

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

count(if(date#(time,'D + HH:MM:SS')>='2 + 00:00:00',Articles))

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Can you paste some sample data please

Anonymous
Not applicable
Author

Articles, time:

a, 2 + 00:00:00

b, 2 + 00:00:00

c, 3 + 00:00:00

b, 2 + 00:00:00

a, 3 + 00:00:00

b, 5 + 00:00:00

a, 1 + 00:00:00

The expression “if(time >=’2 + 00:00:00’, Count(DISTINCT(a),0)” should return "2", since two of the articles "a" have a time >=2, but it returns "0".

Anonymous
Not applicable
Author

if(date#(time,'D + HH:MM:SS')>='2 + 00:00:00',count(DISTINCT(Article)),0)

MK_QSL
MVP
MVP

=COUNT((IF(Timestamp#([time:],'D + hh:mm:ss') >= Timestamp#('2 + 00:00:00','D + hh:mm:ss'),Articles)))

rubenmarin
MVP
MVP

Hi Charlotte, another option:

=If(SubField(time, ' + ', 1)>=2, Count(DISTINCT(article),0))

and another one:

1.In the script create the field Days (or similar) like "SubField(time, ' + ', 1) as Days"

2.Then you can use this field in expression:

=If(Days>=2, Count(DISTINCT(article),0))


or maybe it should be:

=Count(DISTINCT {<Days={">=2"}>} article)

Anonymous
Not applicable
Author

count(if(date#(time,'D + HH:MM:SS')>='2 + 00:00:00',Articles))