BookmarkSubscribeRSS Feed
sat_lr
Calcite | Level 5

Hi,

I have invoice list with dates. As the customer wants to see sales by week, I would like to consume the date in the form of Weeks with numbers. ex: week 1, week 2 week 3 with sales figures.

All I have is dates. I am able to manipulate my dates with all the options available like weekdays, quarter (q1, q2, q3, q4) etc. But I couldn't get weeks with number option.

Pls help with your suggestions. Thanks.

cheers

-satlr

4 REPLIES 4
PeterWijers
Lapis Lazuli | Level 10

Hi Sat_Ir,

If you have a dataset with a date  (Invoice date) you can use the week number function   (VA 6.3)

Create a new Calculated Item and use the formula  week number(Invoice date).

Now you get the week number of the Invoice date.  Do not forget to switch the numeric field to a Category before you start using it.

Ones it is a category, you can use it as a label in graphs or tables.

Sure this will work.

Otherwise this is the mathematical function

week_nr= INT(1+int((date+(3-mod(weekday(date)+5,7))-intnx('year',date+(3-mod(weekday(date)+5,7)),0))/7));

Greetings

sat_lr
Calcite | Level 5

brilliant! thanks Wijers. will try to incorporate this expression.

cheers.

satlr

NikNizan
Calcite | Level 5
Hi, my problem is somewhat similar as I would like to use WeekNum as a Date Measure for the Geo Bubble Map looping animation slider. WeekNum once converted to Category doesn't allow it to be used as an Animation variable. Any workaround?
Sam_SAS
SAS Employee
Hello,

Animation requires a date, time, or datetime variable.

Unfortunately, I don't think there is any way to create a date from week number in VA.

In theory such a thing could be possible if you provide the year and the week number, but VA does not offer a function to do this calculation.

Thanks,
Sam

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 4532 views
  • 5 likes
  • 4 in conversation