Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I add a calcuation to set analysis? IF function?

Hi All--

I am looking to use the below set analysis but also add a dimension using a date calc/IF function. I need to count a distinct number of pick up moves (PUP) if the (Stop Time - the Arrival time) is between -120 and 120 minutes.

I have the distinct part covered but I am unsure how to add the calculated part to it.

count(DISTINCT{$<[Stop Type] ={'PUP'}>}[TMW move#])

Thank you!

Jessica

2 Replies
Anil_Babu_Samineni

I would suggest you to create in script like

Sample:

Load [stop time],

        [arrival time],

        If(Inteval([stop time] - [arrival time],'HH') >= '-120' and Inteval([stop time] - [arrival time],'HH') <= '120', 1, 0) as Flag,

        [Stop Type],

        [TMW move#]

From <Data Source>;


Or


Sample:

Load [stop time],

        [arrival time],

        [Stop Type],

        [TMW move#]

From <Data Source>;

Left Join (Sample)

Load *,

        If(Inteval([stop time] - [arrival time],'HH') >= '-120' and Inteval([stop time] - [arrival time],'HH') <= '120', 1, 0) as Flag

Resident Sample;

Create Dimensions and expression like

Count({<[Stop Type] = {PUP}, Flag = {1}>} DISTINCT [TMW move#])

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
sunny_talwar

May be this

Count(DISTINCT{$<[Stop Type] ={'PUP'}, [TMW move#] = {"=fabs([Stop Time] - [Arrival time]) <= MakeTime(2)"}>}[TMW move#])