Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
poooja
Creator
Creator

Number of Weeks

Hi Qlikies,


Please help me with some logic for the  Broken weeks . I am expecting the result as Below.

'Total Number of weeks in the current month.

WeekNumberDayDateBudget
1Friday1/4/2019500
2Friday1/11/2019500
3Friday1/18/2019500
4Friday1/25/2019500
5Thursday1/31/2019500
1Friday2/8/2019600
2Friday2/15/2019600
3Friday2/22/2019600
4Thursday2/28/2019600
1Friday3/8/2019400
2Friday3/15/2019400
3Friday3/22/2019400
4Sunday3/31/2019400
1Friday4/5/2019800
2Friday4/12/2019800
3Friday4/19/2019800
4Friday4/26/2019800
5Tuesday4/30/2019800
1Friday5/10/2019400
2Friday5/17/2019400
3Friday5/24/2019400
4Friday5/31/2019400
1Friday6/7/2019700
2Friday6/14/2019700
3Friday6/21/2019700
4Sunday6/30/2019700
1Friday7/5/2019300
2Friday7/12/2019300
3Friday7/19/2019300
4Friday7/26/2019300
5Wednesday7/31/2019300
1Friday8/9/2019500
2Friday8/16/2019500
3Friday8/23/2019500
4Saturday8/31/2019500
1Friday9/6/2019900
2Friday9/13/2019900
3Friday9/27/2019900
4Monday9/30/2019900
1Friday10/4/2019900
2Friday10/11/2019200
3Friday10/18/2019200
4Friday10/25/2019200
5Thursday10/31/2019200
1Friday11/8/2019400
2Friday11/15/2019400
3Friday11/22/2019400
4Saturday11/30/2019400
1Friday12/6/2019500
2Friday12/13/2019500
3Friday12/20/2019500
4Friday12/27/2019500
5Friday12/31/2019500
2 Replies
Vegar
MVP
MVP

Try this:

QlikCommunityTable:
LOAD //WeekNumber, 
     Day, 
     num(Date) as %date, 
     Budget
FROM
[https://community.qlik.com/t5/QlikView-App-Development/Number-of-Weeks/m-p/1553953#M440500]
(html, codepage is 1252, embedded labels, table is @1);

for _date = date('1/4/2019') to date('12/31/19')
	Calendar:
	LOAD 
		'$(_date)' as %date,
		date('$(_date)') as Date,
		weekname('$(_date)')   as WeekName,
		week('$(_date)')   as Week,
		autonumber(weekname('$(_date)') , 'ws')  - autonumber( weekname( monthstart('$(_date)')), 'ws') +1  as WeekNumber
	AutoGenerate 1;	
next

image.png

I do get a diff  from you. Eg 2/8/2019, I get WeekNumber = 2 and in your table it is = 1, but if you study the calendar you'll see that it is the second week in February.

image.png

poooja
Creator
Creator
Author

Hi,

In your output we are missing week number 1 for most of the months.  eg 2/8/2019, Tough its second week in February calendar I am combining the first week also since it has only  2 days.  

Thanks!

Pooja