Javad Kondori Posted November 24, 2021 Share Posted November 24, 2021 (edited) 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. Edited November 24, 2021 by Javad Kondori Link to comment Share on other sites More sharing options...
Thorsten Vogt Posted November 25, 2021 Share Posted November 25, 2021 Hi Javad, I got a solution based on this starting point: 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) ) Changing capsule duration of B gets no capsule for result, which is expected: 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: Changing duration of capsule B to its original value show capsules of A as the result: Hope this helps. Regards, Thorsten 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now