cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.
  • See how to access JMP Marketplace - and - find, create & share add-ins to extend your JMP. Watch video.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
hogi
Level XIII

helpful Custom Functions

You know a cool trick / helpful gimmick?

-> please share with us : )

 

[More Topic Containers like this]

2 REPLIES 2
hogi
Level XIII

Re: Custom Functions

InFormat doesn't understand Timezone information like +01:00 : (

In Format("2025-01-01T00:00+01:00") // -> .

use this Workaround:

Add Custom Functions(
	New Custom Function(
		"custom",
		"TimeZone_to_Time",
		Function( {col_a},
      {Default Local}, 
				Informat( Word( 1, col_a, "+" ), Empty() )
		+In Hours( Num( Word( 1, Word( 2, col_a, "+" ), ":" ) ) )
),
		<<Formula Category( "Date Time" ),
		<<Transform Category( 1 ),
		<<Description( "takes a Date (String) with Timezone information and converts it to a number \!n works as well as column transform -- please change the format manually" ),
		<<Example(Expr(
		b = date time:TimeZone_to_Time("2025-01-01T00:00+01:00");
			)
		)
	)
);

The disadvantage:
When you use the formula via right click / new formula column, the column will show the date in seconds - instead of 2025-01-01T00:00
... seems that you have to adjust the format manually.

hogi
Level XIII

Re: Custom Functions

Add Custom Functions(
	New Custom Function(
		"hogi",
		"replace head",
		Function( {orig, new Head},
			{Default Local},
			mydummy = Expr( dummy() );
			For Each( {arg}, Name Expr( orig ), Insert Into( mydummy, arg ) );
	
			( Substitute( Name Expr( mydummy ), Expr( dummy() ), Name Expr( new Head ) ) );
		),
		<< description("takes the first argument and replaces its head with the second argument"),
		<< example(Expr(
			hogi:replace head({1,2,{3,4}}, Expr(Show()));
			
			orig = Expr(Max(1,2,3));
			hogi:replace head(Name Expr(orig), Expr(Show()));			
		))
	)
);

Recommended Articles