cancel
Showing results for 
Search instead for 
Did you mean: 

PB7. Compute Field.Compute Expression Help

Former Member
0 Kudos

Friends,

formula 1:

Sum( If( compute_6 = "Fail", 1, 0 ) For Group 1 ) === failed count

Formula 2:

count( compute_6 for group 1 )   ===== no. of rows

i am not able to use the below code. can anybody correct me the code?

if Sum( If( compute_6 = "Fail", 1, 0 ) For Group 1 ) >= 3 then "Ask your ward to see the class teacher"

else if

Sum( If( compute_6 = "Fail", 1, 0 ) For Group 1 ) <= 2 then "Ask your ward to concentrate more on the failed subjects"

else if

Sum( If( compute_6 = "Pass", 1, 0 ) For Group 1 ) = count( compute_6 for group 1 ) then "Well Done Keep it up"

end if

thanks..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You're trying to write PowerScript into a datawindow computed expression.  That's not correct...

The IF THEN ELSE ENDIF syntax is PowerScript, used inside event and function scripts.

The datawindow expression uses the IF() function - and since you have multiple conditions/results, I'd recommend using the CASE() function.

CASE(

  sum( if( compute_6 = 'Fail', 1, 0) for group 1)

  when 0 then 'Well Done Keep it up'

  when 1,2 then 'Ask your ward to concentrate more on the failed subjects'

  when is >= 3 then 'Ask your ward to see the class teacher'

)

-Paul Horan-

IBM

Former Member
0 Kudos

Hi Paul..

So you have a new work in IBM?

Andreas.

Former Member
0 Kudos

sorry for opening this thread again...

CASE(

  sum( if( compute_6 = 'Fail', 1, 0) for group 1)

  when 0 then 'Well Done Keep it up'

  when 1,2 then 'Ask your ward to concentrate more on the failed subjects'

  when is >= 3 then 'Ask your ward to see the class teacher'

)

now the situation is compute_6 is null but the code is executing the first condition that is...

when 0 then 'Well Done Keep it up'

if compute_6 is null i dont want to show anything..just a null space ...

where i have to make a change for getting a null value?

thanks

Former Member
0 Kudos

Just add another WHEN expression.  Make sure it's the first one in the list.

CASE(

  sum(...)

  when is null then ' '

  when 0

   ...

-Paul-

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sathy;

   Have you tried ...

Sum( If( Lower(compute_6) = "pass", 1, 0 )

Also, maybe a Trim() in there as well to remove blanks?

Regards ... Chris

Former Member
0 Kudos

Create a new compute that returns 0 or 1, based on compute_6=Fail/Pass, or base the new compute on the code that creates Pass/Fail. Use the new compute in place of compute_6 for the Sum function calls.