Subscribe Bookmark RSS Feed

How to sort week number across year using JSL (JMP12)?

Priyank

New Contributor

Joined:

Jan 18, 2017

I have data by week number from Oct 2016 to the current week.  I want to show the week numbers in correct order on the X-axis on bar chart going from week 48, 49, 50, 51, 1,2,3 etc. Or value ordering for WeekNumber column in the order of time stamp can help.

I created Year as another column and used Year axis along with WeekNum on Bar chart. But it didn't work as expected. please see the attached charts. Left one is the one I am getting right now, and the right one is the desired one. For a small dataset, we can reorder the WW values but it's tedious for a large data set. 

I am using JMP12, it will be a big help if anyone can suggest a solution.

 

 BarCharts.PNG

 

 

4 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Without seeing what you want your final product to look like, I will guess that what you may need to do is to change the Year and work week moding types to ordinal.  Assuming the year and word week columns are numeric that should make the axis work out the way you want it to.

Jim
Priyank

New Contributor

Joined:

Jan 18, 2017

Solution

Thanks Jim. Yes, WW and Year are in numeric. but it didnt work out with ordinal modeling types for these columns. 

Please see the attached chart. Desired chart is in the right and the one i am getting is in the left. Notice the week numbers. I had to reorder the week numbers to 49, 50, 51, 52, 1, 2.. which is quite tedious with large data set. Also i want to put it in script. 

 

BarCharts.PNG

txnelson

Super User

Joined:

Jun 22, 2012

Solution

If you use Chart Builder, setting Year and Work Week to Ordinal and dragging both of them at the same time to the X axis and then drag the Y variable to the Y axis you will get the below chart

work week.PNG

Jim
Priyank

New Contributor

Joined:

Jan 18, 2017

Solution

Thanks so much for the help Jim. It worked.

Now i have to add this capability into my script. Was looking on web but didnt find any solution. Please let me know if you can suggest something.  

5 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Without seeing what you want your final product to look like, I will guess that what you may need to do is to change the Year and work week moding types to ordinal.  Assuming the year and word week columns are numeric that should make the axis work out the way you want it to.

Jim
Priyank

New Contributor

Joined:

Jan 18, 2017

Solution

Thanks Jim. Yes, WW and Year are in numeric. but it didnt work out with ordinal modeling types for these columns. 

Please see the attached chart. Desired chart is in the right and the one i am getting is in the left. Notice the week numbers. I had to reorder the week numbers to 49, 50, 51, 52, 1, 2.. which is quite tedious with large data set. Also i want to put it in script. 

 

BarCharts.PNG

txnelson

Super User

Joined:

Jun 22, 2012

Solution

If you use Chart Builder, setting Year and Work Week to Ordinal and dragging both of them at the same time to the X axis and then drag the Y variable to the Y axis you will get the below chart

work week.PNG

Jim
Priyank

New Contributor

Joined:

Jan 18, 2017

Solution

Thanks so much for the help Jim. It worked.

Now i have to add this capability into my script. Was looking on web but didnt find any solution. Please let me know if you can suggest something.  

txnelson

Super User

Joined:

Jun 22, 2012

Are you asking, what is the JSL to do this chart?  If this is your question, just go ahead and interactively create the chart, then go to the red triangle, click on it and got to Save the Script.  You will get the code required to regenerate the chart.

Jim