# Qlik Sense App Development

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

## calculation expression , display answer in as...

Hiya

I have a an time expression calculation

interval(avg(ShoppingTime)/1440,'h:mm') - interval(avg(ActualShoppingTime)/1440,'h:mm')

I wish to if the answer is a minus, just show 00:00:00 and not e.g - 01:00:00

1 Solution

Accepted Solutions
Not applicable

## Re: calculation expression , display answer in as...

May be this:

Interval(If(Avg(ShoppingTime) - Avg(ActualShoppingTime) <= 0, 0, (Avg(ShoppingTime) - Avg(ActualShoppingTime))/1440), 'h:mm')

4 Replies
Not applicable

## Re: calculation expression , display answer in as...

Try

=fabs(interval(avg(ShoppingTime)/1440,'h:mm') - interval(avg(ActualShoppingTime)/1440,'h:mm'))

- fabs() function returns the absolute value of x. The result is a positive number.

Not applicable

## Re: calculation expression , display answer in as...

I think you will need an if-check like:

interval(if(avg(ShoppingTime) <  avg(ActualShoppingTime), 0,

(avg(ShoppingTime) - avg(ActualShoppingTime)) /1440),'h:mm')

- Marcus

Not applicable

## Re: calculation expression , display answer in as...

May be this:

Interval(If(Avg(ShoppingTime) - Avg(ActualShoppingTime) <= 0, 0, (Avg(ShoppingTime) - Avg(ActualShoppingTime))/1440), 'h:mm')

Not applicable

## Re: calculation expression , display answer in as...

awesome thank you , worked brill

Community Browser