Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
priyasawant
Creator II
Creator II

Numbering Month list

Hi,

I have a list of Month so would have to number them from 1,2,3,4 and so as as keeping the Max month as 1

For e.g.

Load Proposal Number,

MonthName

From xyz.qvd

 

Monthname will have Dec 2019

Jan 2020

Feb 2020

March 2020

April 2020

May 2020

June 2020

July 2020 and so on,

So here Max month i.e. May 2020 will be 1 

April 2020 will be 2

March 2020 will be 3

Feb 2020 will be 4

Jan 2020 will be 5

Dec 2019 will be 6

 

2 Replies
tresesco
MVP
MVP

Sort and number them like:

t1:
Load 
	Date(Date#(MonthName, 'MMM YYYY'),'MMM YYYY') as MonthName
Inline [
MonthName
Dec 2019
Jan 2020
Feb 2020
Mar 2020
Apr 2020
May 2020];

t2:
Load 
	MonthName,
	RowNo() as MonthNum
Resident t1 Order by MonthName Desc;

Drop Table t1; 	

Capture.PNG

Vegar
MVP
MVP

See script below 

Vegar_1-1589266205561.png

 

 

SET vL.FirstMonthOfFiscalYear= 5;
[Numbering Month list]:
LOAD *,
  Month(MonthName) as Month,
  Year(MonthName) as Year,
  YearName([MonthName],0,$(vL.FirstMonthOfFiscalYear)) as FiscalYear,
  Dual(Date([MonthName],'MMM'), 
       Num(Month(Monthname([MonthName],-$(vL.FirstMonthOfFiscalYear)+1)))
       )  as FiscalMonth
;
//Below data equvialent to the example in your post
Load Monthname(Date) as MonthName, recno() as [Proposal Number] inline [
Date
2020-01-01
2020-01-15
2020-02-01
2020-02-15
2020-03-01
2020-03-15
2020-03-20
2020-04-01
2020-04-15
2020-05-01
2020-05-15
2020-06-01
2020-06-15
2020-06-20
2020-06-30
2020-07-01
2020-07-15
2020-08-01
2020-08-15
2020-09-01
2020-09-15
2020-10-01
2020-10-15
2020-11-01
2020-12-01
2020-12-15
2021-01-01
2021-02-16
2021-02-01
2021-02-15
2021-03-01
2021-03-15
2021-03-20
2021-04-01
2021-04-15
2021-05-01
2021-05-15
2021-06-01
2021-06-15
2021-06-20
2021-07-30
2021-07-01
2021-07-15
2021-07-01
2021-08-15
2021-09-01
2021-09-15
2021-10-01
2021-10-15
2021-11-01
2021-12-01
2021-12-15
];