Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Year, Quarter, Month Selection List Box

Hi All,

I have written this code

--------------------------------------

LOAD DISTINCT

    [Invoice Date],

    Year([Invoice Date]) as Year,

    Month([Invoice Date]) as Month,

    Date(Monthstart([Invoice Date]), 'D-MMM-YY') as YearMonth,

    'Q' & Ceil(Month([Invoice Date])/3) as Quarter,

    Dual(Year([Invoice Date]) & '-Q' & Ceil(Month([Invoice Date])/3), Year([Invoice Date]) & Ceil(Month([Invoice Date])/3)) as YearQtr,

    Week([Invoice Date]) as Week

RESIDENT InvoiceDetail;   

-------------------------------------------

but it is showing quarter as

I dont want this "Q". There is no record also associated with "Q" when I click it. I need Q1, Q2, Q3 and Q4.

Please advise.

BR,

SAK

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

This may load faster if InvoiceDetail is a large table.

[Calendar]:
LOAD *,
Year([Invoice Date]) as Year,
Month([Invoice Date]) as Month,
Date(Monthstart([Invoice Date]), 'D-MMM-YY') as YearMonth,
'Q' & Ceil(Month([Invoice Date])/3) as Quarter,
Dual(Year([Invoice Date]) & '-Q' & Ceil(Month([Invoice Date])/3), Year([Invoice Date]) & Ceil(Month([Invoice Date])/3)) as YearQtr,
Week([Invoice Date]) as Week
;
LOAD date(fieldvalue('Invoice Date',recno())) as [Invoice Date]
AUTOGENERATE fieldvaluecount('Invoice Date')
;

I think that will also avoid any null invoice dates, so I don't think it would need the Rob/Mayil change in this case.

View solution in original post

13 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

if(len( [Invoice Date]) > 0

,'Q' & Ceil(Month([Invoice Date])/3

,''

) as Quarter

-Rob

MayilVahanan

HI

Try like this

If(Len(Trim([Invoice Date])) > 0, 'Q' & Ceil(Month([Invoice Date])/3))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
johnw
Champion III
Champion III

This may load faster if InvoiceDetail is a large table.

[Calendar]:
LOAD *,
Year([Invoice Date]) as Year,
Month([Invoice Date]) as Month,
Date(Monthstart([Invoice Date]), 'D-MMM-YY') as YearMonth,
'Q' & Ceil(Month([Invoice Date])/3) as Quarter,
Dual(Year([Invoice Date]) & '-Q' & Ceil(Month([Invoice Date])/3), Year([Invoice Date]) & Ceil(Month([Invoice Date])/3)) as YearQtr,
Week([Invoice Date]) as Week
;
LOAD date(fieldvalue('Invoice Date',recno())) as [Invoice Date]
AUTOGENERATE fieldvaluecount('Invoice Date')
;

I think that will also avoid any null invoice dates, so I don't think it would need the Rob/Mayil change in this case.

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

Check whether all the values in invoice date field is in correct date format.

Not applicable
Author

Some syntax error I think.. not relaoding...

LOAD DISTINCT

    [Invoice Date],

    Year([Invoice Date]) as Year,

    Month([Invoice Date]) as Month,

    Date(Monthstart([Invoice Date]), 'D-MMM-YY') as YearMonth,

    If(Len(Trim([Invoice Date])) > 0, 'Q' & Ceil(Month([Invoice Date])/3)) as Quarter

    Dual(Year([Invoice Date]) & '-Q' & Ceil(Month([Invoice Date])/3), Year([Invoice Date]) & Ceil(Month([Invoice Date])/3)) as YearQtr,

    Week([Invoice Date]) as Week

RESIDENT InvoiceDetail;

Not applicable
Author

As i am new, so i think some error by me in adding your advised code. When I reload, periods not coming up.

LOAD DISTINCT

    [Invoice Date],

    Year([Invoice Date]) as Year,

    Month([Invoice Date]) as Month,

    Date(Monthstart([Invoice Date]), 'D-MMM-YY') as YearMonth,

    if(len( [Invoice Date]) > 0,'Q' & Ceil(Month([Invoice Date])/3,'') as Quarter

    Dual(Year([Invoice Date]) & '-Q' & Ceil(Month([Invoice Date])/3), Year([Invoice Date]) & Ceil(Month([Invoice Date])/3)) as YearQtr,

    Week([Invoice Date]) as Week

RESIDENT InvoiceDetail;

Not applicable
Author

Thanks John! It works great.

1) I think Load * is same as Load distinct?

2) As I dont need Year-Month and Year-Quarter, after trial and error in puting comma and semi-colon at right places, I wrote like this and it is working ok.

[Calendar]:

LOAD *,

Year([Invoice Date]) as Year,

Month([Invoice Date]) as Month,

'Q' & Ceil(Month([Invoice Date])/3) as Quarter

;

LOAD date(fieldvalue('Invoice Date',recno())) as [Invoice Date]

AUTOGENERATE fieldvaluecount('Invoice Date')

;

Not applicable
Author

Format is ok, need to put fuctionlaity to not to consider nil values or suppress nil values in date coulmn. It's working ok with John code, Rob/mayil code I may not have been able to merge correctly.

Not applicable
Author

Dear John/All

I dont have any associated data with selection 2011(Year) and Q2(quarter). But when I click 2011 and then Q2, it brings data assocated with 2012 and Q2. Upon clicking Q2, 2012 gets selected and 2011 deselected. Is there any way that it does not jump to 2012 until selected 2012 and Q2?  Because if a user has selected 2011, it means he does not want to see 2012 at the moment.

Please advise about code to maintain natural flow of viewing and it does not jump to unwanted period.

BR,

SAK