Jump to content

Capsule duration


Recommended Posts

Hi all,

Does anyone have any idea for the following statement?

"Select A, If Duration of B>D and D>C
or Select A if B started before D and C"

or anything to select all capsules of A by comparison of capsule (B-C-D) durations.

 

 


image.png.6195fff6146ac7dcb954e311cbabc2e0.png

 

Edited by Javad Kondori
Link to comment
Share on other sites

Hi Javad, 

I got a solution based on this starting point:
image.thumb.png.ee1a29da7cfae9f228f6076fc0a76459.png

The following formula compares the durations of the first capsules for conditions B,C and D bounded by each capsule of condition A and sets a property on capsules of condition A indicating if these should be shown. The keep function on the end only displays capsules where the property is set to true

$a.transform($a_capsule -> {
 
 $b_capsule = $b.toGroup($a_capsule).first()
 $c_capsule = $c.toGroup($a_capsule).first()
 $d_capsule = $d.toGroup($a_capsule).first()
 $show_a = ($b_capsule.duration() > $d_capsule.duration() and  $d_capsule.duration() > $c_capsule.duration())
 $a_capsule.setProperty('show', $show_a)
}, 40h).keep('show', isequalTo(true) )

image.thumb.png.49d924c51018129f61b37eb7a34c04c9.png

Changing capsule duration of B gets no capsule for result, which is expected:
image.thumb.png.c21d5cdadc22fff64a66a182fd1b140f.png

 

If you want to show another capsule for the last case, you can adjust the formula to generate another condition with the property show set to the inverse and select one of the conditions based on that value. Therefore you have to do the transform twice:

$tempCondition1 = $a.transform($a_capsule -> {
 
 $b_capsule = $b.toGroup($a_capsule).first()
 $c_capsule = $c.toGroup($a_capsule).first()
 $d_capsule = $d.toGroup($a_capsule).first()
 $show_a = ($b_capsule.duration() > $d_capsule.duration() and  $d_capsule.duration() > $c_capsule.duration())
 $a_capsule.setProperty('show', $show_a)
}, 40h)


$tempCondition2 = $tempCondition1.transform($a_capsule -> {
 $d_capsule = $d.toGroup($a_capsule).first()
 $d_capsule.setProperty('show', not $a_capsule.property('show'))
}, 40h)

$tempCondition1.keep('show', isequalTo(true)) or $tempCondition2.keep('show', isequalTo(true))

As a result capsules for condition D are shown:

image.thumb.png.042f858ad3906a7640913309c8f33309.png

Changing duration of capsule B to its original value show capsules of A as the result:

image.thumb.png.ec7f3ce717aca80234f53a83f7d8e302.png

Hope this helps.

Regards,

Thorsten

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...