Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Highlighted
Not applicable

If Statement

I have a if statement that is to look at a number and if the number is above 15 to show the words delayed if it is under 15 or a negative value should display not delayed.

At present it is only displying not delayed for every result. going forward I want to be able to calculate the total amount of delayed and not delayed by day week month and year.

i have attahced a sample of my data where you can see the issue

1 Solution

Accepted Solutions
flipside
Valued Contributor II

Re: If Statement

I may be misunderstanding your requirement but it looks to me that you need some sort of aggregation in your expression (sum, avg, max etc) otherwise you will return null and the comparison will fail hence only one value is returned.

I'm not sure why you are using the variable, but doesn't this work ...

=if(avg(CHKS-SCH)>0.010416666671517,'Delayed','Not Delayed')

I would probably use this instead though ...

=if(avg(CHKS-SCH)*24*60>15,'Delayed','Not Delayed')

flipside

16 Replies
Not applicable

Re: If Statement

Sorry I should have put the if statement I am currently using:

if($(DELAYMINS)>0.010416666671517,'Delayed','Not Delayed')

MVP
MVP

Re: If Statement

Hi,

PFA file.

Regards,

Jagan.

Not applicable

Re: If Statement

Im not able to open up files once you have resaved it as I am using the personal free edition.

please could you submit the changes on here and i will do them within Qlikview

jonathan_dau
New Contributor III

Re: If Statement

Hi,

Don't you think it's a problem related to the definition of you variable DELAYMINS ?

If you try DELAYMINS = Minute(Frac(SCH)-Frac(CHKS)) ??

Hope that will help.

Jonathan

MVP
MVP

Re: If Statement

Hi,

Try this expression

=if(Minute(Frac(Sum(CHKS))-Frac(Sum(SCH))) >0.010416666671517,'Delayed','Not Delayed')

Regards,

Jagan.

Not applicable

Re: If Statement

Hi Jonathan,

I have changed the variable and so far it seems to work why would that make a difference can you explain?

Not applicable

Re: If Statement

Hi Jagan this has worked correctly thank you.

could you explain why referring to the variable?

jonathan_dau
New Contributor III

Re: If Statement

Hi,

First I think your expression was not rightly writen :

Minute(Frac(Timestamp1)-Frac(Timestamp2)) --> Minute(Frac(Timesstamp1)-Frac(Timestamp2))

And after I don't really see the point of puting SCH and CHKS into variables.

But I just had a quick look and I'm not sure it works according to your needs.

Regards

Jonathan

Not applicable

Re: If Statement

Sorry after looking at a larger set of results it is not populating the correct output.