Help with Changing Multiple If Statement to a Case Statement
I need help converting this multiple if statement to a case statement. Withdrawn and Graduated fields are yes/no.
if Withdrawn = 0 and Graduated = 0 then
let t := 'Enrolled Date';
days(date('Enrolled Date'), today()) -
cnt(select 'Academic Breaks' where Date >= t and Date <= today())
else
if Withdrawn = 1 and Graduated = 0 then
let t := 'Enrolled Date';
let y := 'Withdrawal Date';
days(date('Enrolled Date'), 'Withdrawal Date') -
cnt(select 'Academic Breaks' where Date >= t and Date <= y)
else
if Withdrawn = 0 and Graduated = 1 then
let t := 'Enrolled Date';
let x := 'Graduation Date';
days(date('Enrolled Date'), 'Withdrawal Date') -
cnt(select 'Academic Breaks' where Date >= t and Date <= x)
end
end
end
10 replies
-
Or if someone can get this to work for me just using if statements. That would work to. I can get it two work with just 2 if statements, but I get no value on any record when using 3 if statements.
-
Try this
let t := 'Enrolled Date'; let y := 'Withdrawal Date'; let x := 'Graduation Date'; switch Withdrawn * 1 + Graduated * 2 do case 0: days(date('Enrolled Date'), today()) - cnt(select 'Academic Breaks' where Date >= t and Date <= today()) case 1: days(date('Enrolled Date'), 'Withdrawal Date') - cnt(select 'Academic Breaks' where Date >= t and Date <= y) case 2: days(date('Enrolled Date'), 'Withdrawal Date') - cnt(select 'Academic Breaks' where Date >= t and Date <= x) end
Regards John
-
said:
switch Withdrawn * 1 + Graduated * 2 doI'm confused at this operator.
-
Your if statements used two test values which we need to convert to one for the switch
When Withdrawn = 0 and Graduated = 0, 0 * 1 + 0 * 2 = 0
When Withdrawn = 1 and Graduated = 0, 1 * 1 + 0 * 2 = 1
When Withdrawn = 0 and Graduated = 1, 0 * 1 + 1 * 2 = 2
Regards John
-
I receive invalid operator: booleon * number at line 4....and same with the next *
-
It took some time, but I fixed it. Had to add number(Withdrawn) and number(Graduated)
-
you can also do:
let t := 'Enrolled Date'; switch true do case Withdrawn = 0 and Graduated = 0: days(date('Enrolled Date'), today()) - cnt(select 'Academic Breaks' where Date >= t and Date <= today()) case Withdrawn = 1 and Graduated = 0: let y := 'Withdrawal Date'; days(date('Enrolled Date'), 'Withdrawal Date') - cnt(select 'Academic Breaks' where Date >= t and Date <= y) case Withdrawn = 0 and Graduated = 1 then let x := 'Graduation Date'; days(date('Enrolled Date'), 'Withdrawal Date') - cnt(select 'Academic Breaks' where Date >= t and Date <= x) end
Content aside
-
1
Likes
- 8 mths agoLast active
- 10Replies
- 84Views
-
4
Following