One Star

## Ternaire condition

Hello,
Is it possible to have, in a tMap, a ternaire condition as :
toto=1?Var.cptY+1 and "YES":Var.cptN+1
-----------------------
ie two actions il a ternaire condition.
Quartz
Moderator

## Re: Ternaire condition

Hi,
In the tmap, the formula must return a value that will be assigned to the output column of your schema. Then, you can't use if/then/else statements in it.
Instead, use conditional operator "?" like this :
(condition) ? then_value : else_value
That is the ternaire condition
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

## Re: Ternaire condition

Hello,
Yes, but
(condition) ? then_value : else_value
in the then_value, (or in the else_value or the both), is it possible to have two actions, one who assign a value in the output column, and another as cpt+1 to display it after ?
Best regards,
Quartz
Moderator

## Re: Ternaire condition

Hi,
 in the then_value, (or in the else_value or the both), is it possible to have two actions, one who assign a value in the output column, and another as cpt+1 to display it after ?

Could you please elaborate your case with an example with input and expected output values?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

## Re: Ternaire condition

Sabrina,
In a tMap, I have this expression to assign a value in output column :
!Relational.ISNULL(File_Ei.NAME)?File_Ei.Name:"NoName"
and (in more) I want count how many input null and no null I have.
Can I do :
!Relational.ISNULL(File_Ei.NAME)?File_Ei.Name Var.cptnoNull+1:"NoName" Var.cptNull+1
for displaying the two counters after, in an another steep.
More generally, is it possible to have more than one action in then_value or/and else_value in a ternaire condition ?
Quartz
Moderator

## Re: Ternaire condition

Hi,
I think the Ternaire condition in tMap cannot achieve that.
But you create a routine to do it Managing routines
for example:
`condition? MyRoutine.methodIfTrue():MyRoutine.methodIfFalse()`

and you can define a variable in the routine that is accessable from the same job or other job
Can I define a variable that is accessible from multiple Jobs?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

## Re: Ternaire condition

Thank you, Sabrina
Qartz92