cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
hogi
Level XI

calendar week?

year-week can be calculated in different ways.

a)  via the right click context menu/new formula column :

hogi_0-1718715994958.png

 

b) via Time Bins in Graph Builder [via DateIncrement(date, 0)]

hogi_3-1718717865983.png

 

This plots shows both values in the same graph.
On the top is: week by binning in Graph Builder, the bottom graph shows the week calculated via new formula column:

hogi_4-1718718395932.png

 

Why is "week" not defined consistently at both places ?!?

How can I make the weekly binning in Graph Builder start on a Monday ?!?


dt = New Table( "test",
	Add Rows( 30 ),
	Compress File When Saved( 1 ),
	New Column( "date",
		Format( "y/m/d", 12 ),
		Formula( Date DMY( 1, 1, 2024 )+ row()*24*60*60 )
	)
);
dt << New Formula Column(
	Operation( Category( "Date Time" ), "Year Week" ),
	Columns( :date )
);

dt << New Formula Column(
	Operation( Category( "Date Time" ), "Day of Week Name" ),
	Columns( :date )
);

wait(0);

dt << Data Filter(
	Add Filter(	columns( :Day of Week ),Where( :Day of Week == "Sunday" )	)
);


dt << Graph Builder(
	Transform Column(
		"Week[date]",
		Format( "Format Pattern", "<YYYY></><MM></><DD>", 15 ),
		Formula( Date Increment( :date, "Week", 0 ) )
	),
	Variables(
		X( :date ),
		Y( :"Week[date]"n ),
		Y( :Year Week ),
		Color( :Day of Week )
	),
	Elements( Position( 1, 1 ), Points( X, Y, Legend( 7 ) ) ),
	Elements( Position( 1, 2 ), Points( X, Y, Legend( 12 ) ) ),
);
3 REPLIES 3
shampton82
Level VII

Re: calendar week?

I use these scripts to bin dates as either the Monday of the week or the Sunday of the week.  It would be nice if these were built in options for new formula columns.\

 

Steve

hogi
Level XI

Re: calendar week?

Actually, I am fine with what  new formula column generates - with Monday as first day of the week

My issue is the Date/Time Binning in Graph Builder.

Date Increment( :date, "Week", 0 )

is a cool trick - but the developer of this functions seems to work in another country than me.

 

 

 

shampton82
Level VII

Re: calendar week?

Ah I see now, I didn't follow your chart correctly.  Its isn't the first time in JMP that platforms don't align in their actions.  Probably the downside of a program being able to do so much, hard to keep everything aligned.  

 

Steve