Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

mhmmd_srf
Contributor

Division Calculation is not working

Hi All,

I have below table on my present data set.

See very first row. I want Duration/Count = 58/1 = 58 and similarly for other rows. And In summary level also it is sum(duration) / count(number). But this is showing some weird value.

My Script:

Duration = Interval([closed_at] - [sys_created_on] ,'mm')

Number Count = count(number)

Duration/Count = Interval([closed_at] - [sys_created_on] ,'mm')/count(number)

Could you please help on this.

Thanks,

Sarif

1 Solution

Accepted Solutions

Re: Division Calculation is not working

Your fields closed_at and sys_created_on are timestamp fields. Timestamp fields have numeric value and the unit of those values is in days. If you subtract two of those values you get a result that's also in units of a day. The interval function doesn't change the numeric value, but only the way it is displayed.

A day has 24 hours. An hour has 60 minutes. So a day has 24*60 = 1440 minutes.


talk is cheap, supply exceeds demand
5 Replies

Re: Division Calculation is not working

Duration is really a number that's a fraction of a day. You merely format it so it shows as minutes. The actual value is 1440 times less (24 hours * 60 minutes). So multiply Duration/Count with 1440 and you'll see the numbers you expect.


talk is cheap, supply exceeds demand
beck_bakytbek
Valued Contributor III

Re: Division Calculation is not working

Hi Mohammad,

check this: Evaluate() Function

i hope that helps

beck

mhmmd_srf
Contributor

Re: Division Calculation is not working

hi gysbert..it is matching..however I could not understand the logic. It would be really helpful if you can explain it in details.

Thanks,

Sarif

looking for your reply... 

Re: Division Calculation is not working

Your fields closed_at and sys_created_on are timestamp fields. Timestamp fields have numeric value and the unit of those values is in days. If you subtract two of those values you get a result that's also in units of a day. The interval function doesn't change the numeric value, but only the way it is displayed.

A day has 24 hours. An hour has 60 minutes. So a day has 24*60 = 1440 minutes.


talk is cheap, supply exceeds demand
mhmmd_srf
Contributor

Re: Division Calculation is not working

thanks dear..this is helpful ...

Community Browser