cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
saitcopuroglu
Level IV

Script for dynamic date/time axising

I need to reproduce a report every day and the x axis date/time variable should show only the last seven days, and same goes for tabulate and etc... Is there a way to tell JMP by a script?

Thank you all in advance

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Script for dynamic date/time axising

The  Min( 3505939200 ), Max( 3510000000 ) forces the axis to hose limits. Try to delete the entire Send to report(...) part.

Or change it into something like:

Min(today()-in days(7)), Max(today())

View solution in original post

9 REPLIES 9
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Script for dynamic date/time axising

There are multiple ways, as usual, to do it by script. One approach is to hide and exclude the "too old" data table rows.

dt = Current Data Table();

dt << select where(:Name("Date/Time") < Today() - In Days(7));

dt << hide and exclude << clear select;

saitcopuroglu
Level IV

Re: Script for dynamic date/time axising

Thank you.

Even the Data is not displayed, the time axis still displays the hidden/excluded rows.

I actually need both not to be displayed. Does the same script go for the x axis display?

8390_Screen Shot 2015-03-18 at 10.03.16.png

dt = Current Data Table();

dt << select where(:Name("SalesDate") < Today() - In Days(7));

dt << hide and exclude << clear select;

8389_Screen Shot 2015-03-18 at 10.01.33.png

ms
Super User (Alumni) ms
Super User (Alumni)

Re: Script for dynamic date/time axising

Graph Builder usually adapts the axes automatically to show the range of included data only. Are you sure you haven't hard coded the x-axis limits? Check the graph builder script.

saitcopuroglu
Level IV

Re: Script for dynamic date/time axising

"Hard-Coding x-axis limits"? I am afraid I am unaware of that term.

Graph Builder(

  Show Control Panel( 0 ),

  Title Fill Color( "Light Blue" ),

  Title Frame Color( "Medium Dark Gray" ),

  Level Fill Color( {174, 203, 228} ),

  Level Frame Color( "Medium Dark Gray" ),

  Level Underline( 1 ),

  Variables( X( :SalesDate ), Y( :NetRevenue ) ),

  Elements(

  Points( X, Y, Legend( 1 ), Jitter( 1 ) ),

  Smoother( X, Y, Legend( 2 ) )

  ),

  SendToReport(

  Dispatch(

  {},

  "SalesDate",

  ScaleBox,

  {Min( 3505939200 ), Max( 3510000000 ), Interval( "Day" ), Inc( 1 ),

  Minor Ticks( 0 ), Show Major Grid( 1 ), Inside Ticks( 1 ),

  Rotated Labels( "Vertical" )}

  )

  )

)

ms
Super User (Alumni) ms
Super User (Alumni)

Re: Script for dynamic date/time axising

The  Min( 3505939200 ), Max( 3510000000 ) forces the axis to hose limits. Try to delete the entire Send to report(...) part.

Or change it into something like:

Min(today()-in days(7)), Max(today())

saitcopuroglu
Level IV

Re: Script for dynamic date/time axising

Deleting the entire Send To( did not but rewriting the min-max helped.

Thank you a lot!

saitcopuroglu
Level IV

Re: Script for dynamic date/time axising

Hi again,

Would you please keep helping by;

Dynamic date/time scripting for tabulate?

I am okay with graph builder but need to do it also within tabulate local data filter:

I tried to do something like you did with graph builder

  Local Data Filter(

  Location( {56, 0} ),

  Mode( Select( 0 ), Show( 1 ), Include( 1 ) ),

  Add Filter(

  columns( :SalesDate ),

  Where( :SalesDate >= 20Feb2015 & :SalesDate < 14Mar2015 ),

  Display( :SalesDate )

  )

to something like this but it does not work.

  Local Data Filter(

  Location( {34, 0} ),

  Mode( Select( 0 ), Show( 1 ), Include( 1 ) ),

  Add Filter(

  columns( :SalesDate ),

  Where(:Name("SalesDate") < Today() - In Days(7)),

  Display( :SalesDate )

  )

Thank you for your help.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: Script for dynamic date/time axising

It should work fine if you add the missing ")".

tb = Tabulate(...);

tb << Local Data Filter(

    Add Filter(

        columns(:SalesDate),

        Where(:Name("SalesDate") < Today() - In Days(7)),

        Display(:SalesDate)

    )

);

WebDesignesCrow
Super User

Re: Script for dynamic date/time axising

Thanks MS. This is what I'm looking for for my work as well