Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
gitguto
Contributor III
Contributor III

Difference between two dates with a few rules

Hello everyone,

First here's a table to better understand what my data looks like:

gitguto_1-1643296500412.png

I need to create a measure that calculates the difference between the finish date of the activity Study approval and the Start Date of the activity Development Stage for each Request Number. And then, group them in bins and count how many requests took 0~15 days, 16~30 days and 30+days.

But I need to filter out a few things:
1) count only request numbers that have a finish date for both activities. (some request numbers dont have both activities, and some have them both but dont have the finish date for 'study approval')
2) count only request numbers that do NOT have "aux" = 2.

I manage to create the grouped dimensions with this formula, but I can't find a way to filter out these two rules.

sum(aggr(if( only({<name = {'Study approval'}>}activityfinishdate)
-only({<name = {'Development stage'}>}activitystartdate)<16,1,0),[Request Number]))

Here's the chart I'm trying to build:

gitguto_2-1643296878974.png

 

Thank you very much!

1 Reply
chris_djih
Creator III
Creator III

the 2nd condition is quite easy, just add this to your set-analysis: aux -= {2}.
the first condition i would shift into the script:

 

Newtable:
Load 
   RequestNumber,
   If(activityCount+finsihDateCount=4,1,0) as condition_flag
Load
   RequestNumber,
   count(activity) as activityCount,
   count(FinshDate) as finsihDateCount
resident yourtable
group by RequestNumber;

 

You can then add this to your Set-Analysis: condition_flag={1}

If you found help, mark the correct answer and give some likes to ALL contributors, that tried to help.