cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
dfusco923
Level III

How to populate a new column with a conditional statment

I would like to populate column = = :Cost Set_2 with the same data as  from column == :Cost Set 

 

Except if column == :Mon_Yr == 03/2022 AND :Cost Set=="ACTUAL_PAID" THEN :Cost Set_2 == "ACWP"

 

I have a formula script that but I could not get it to work:

 

If( Char( Format( :Mon_Yr, "m/y" ) == "03/2022" ) & (:Cost Set == "ACTUAL_PAID")),
	"ACWP",

 

Also instead of using "03/2022"  I'd like to set this upfront in the jsl code as global variable, how can I do that?

1 ACCEPTED SOLUTION

Accepted Solutions
Georg
Level VII

Re: How to populate a new column with a conditional statment

Probably this will work:

::DATE_SELECT = "03.2022";
If( Format( :Mon_Yr, "m.y" ) == ::DATE_SELECT & :Cost Set == "ACTUAL_PAID",
	"ACWP",
	:Cost Set
);

Instead of setting global variable within the formula code, you can set it elsewhere also.

Please see that my date format is different due to different language settings.

To avoid Syntax problems, I like to use Crtl-M (reformat code) to let JMP show me problems in my (formula) code.

 

See also help and Scripting index, how to use global variables.

Global and Local Variables (jmp.com)

 

 

Georg_0-1646897482093.png

 

Georg

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: How to populate a new column with a conditional statment

You had a misplaced ")".  Try this:

If(Format( :Mon_Yr, "m/y" ) == "03/2022"  & (:Cost Set == "ACTUAL_PAID"),
	"ACWP","")
Jim
dfusco923
Level III

Re: How to populate a new column with a conditional statment

Thank you Jim for your quick response and solution!

 

Georg
Level VII

Re: How to populate a new column with a conditional statment

Probably this will work:

::DATE_SELECT = "03.2022";
If( Format( :Mon_Yr, "m.y" ) == ::DATE_SELECT & :Cost Set == "ACTUAL_PAID",
	"ACWP",
	:Cost Set
);

Instead of setting global variable within the formula code, you can set it elsewhere also.

Please see that my date format is different due to different language settings.

To avoid Syntax problems, I like to use Crtl-M (reformat code) to let JMP show me problems in my (formula) code.

 

See also help and Scripting index, how to use global variables.

Global and Local Variables (jmp.com)

 

 

Georg_0-1646897482093.png

 

Georg
dfusco923
Level III

Re: How to populate a new column with a conditional statment

Thank you for your quick reply and solution!