Hi All,
I’m trying to find a better way to write this expression below.
The expression below returns a list of cards that have a combined duration closed to the requested class duration.
- Fast_Class_Cards is an Enumlist of Ref that represents exercise cards
- Demo_Duration is the duration of the exercise card
- Fast_Class_Duration_Requested is the class duration requested
- Fast_Class_Cards is an Enumlist of Ref of available exercise cards
It works fine but if I want to create class of 100 exercises, I will need to have 100 if statements…
IF(TOTALSECONDS(INDEX([Fast_Class_Cards][Demo_Duration], 1))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],1)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 2)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],2)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 3)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],3)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 4)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],4)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 5)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],5)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 6)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],6)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 7)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],7)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 8)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],8)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 9)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],9)
,
IF(TOTALSECONDS(SUM(TOP([Fast_Class_Cards][Demo_Duration], 10)))>[Fast_Class_Duration_Requested],
TOP([Fast_Class_Cards],10)
,
TOP([Fast_Class_Cards],10)
)
)
)
)
)
)
)
)
)
)
Thank you!
