Subscribe Bookmark RSS Feed

Script for dynamic date/time axising

saitcopuroglu

Community Trekker

Joined:

Sep 29, 2014

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
Solution

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())

8 REPLIES
ms

Super User

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Sep 29, 2014

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

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Sep 29, 2014

"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" )}

  )

  )

)

Solution

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

Community Trekker

Joined:

Sep 29, 2014

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

Thank you a lot!

saitcopuroglu

Community Trekker

Joined:

Sep 29, 2014

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

Joined:

Jun 23, 2011

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)

    )

);