Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
n1ef5ng1
Creator
Creator

Interval on set analysis

Hi guys,

I have a set analysis with this expression

sum({<Region = {'Asia'}>}Amount)

I have an interval involved

Interval(Date1-Date2,'mm') < 121

Basically I need to calculate where the sum of amount for asia only where the difference between the two timestamp are < 121 mins

I def. need to do it all in one expression. cant do it in dimension, is there any way that i can do it.

Thanks

4 Replies
shraddha_g
Partner - Master III
Partner - Master III

Calculate interval in script to create a field and then use that field in set analysis.

sum({<Region = {'Asia'},IntervalField = {"<121"}>}Amount)

Anil_Babu_Samineni

You may try this, I hope you may have separate field for Interval in script

Then, you can use this

Load Region, Date1, Date2, Interval(Date1-Date,'mm') as DateDiff, Amount;

Load Region, Date1, Date2, Amount from DataSource;

sum({<Region = {'Asia'}, DateDiff = {"$(=Hour(DateDiff) < 121/(24*60))"}>} Amount)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
marcus_sommer

You could try:

sum({<Region = {'Asia'}, Amount = {"=Interval(Date1-Date2,'mm')<121"} >} Amount)

or

if(Interval(Date1-Date2,'mm') < 121, sum({<Region = {'Asia'}>}Amount))

whereby it might be useful to do calculation-step within the script like suggested within the other answers.

- Marcus

sunny_talwar

May be this:

Sum({<Region = {'Asia'}>} If(Date1-Date2 < MakeTime(2, 1), Amount))

or

Create Date1-Date2 in script and then like this:

Date1-Date2 as IntervalField


Sum({<Region = {'Asia'}, IntervalField = {$(=121/(24*60))}>} Amount)