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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Convert date field to Q1 Q2...

Hello,

First, thank you for your assistance in helping me with the below issue.

I used the script below in the Expression field to get the quarter name

QuarterName([Date Rqstd])

6-9-2016 4-02-47 PM.jpg

Then to get Q1, Q2, Q3, Q4. I changed the above script to the one below.

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

6-9-2016 4-06-35 PM.jpg

But as you can see there is an extra value "Q".  I checked the field data and there are no nulls.  how do I get it to just show Q1, Q2, Q3, Q4 in the listbox? Again, thank you for your help!

1 Solution

Accepted Solutions
sunny_talwar

Try this:

LOAD [Assigned To],
[Bus. or Dept.],
Leaders,
Comments________________________________,
[T-Shirt Sz],
[Actual Compl. Date],
[Applic. Category],
[Request Title (Linked to SR Doc.)],
[Request Description],
[Demand Type],
Status,
[Rqstd. Compl.],
Created,
Domain,
[Est. Compl. Date],
[Finance Relevant],
ID,
[IS&T Group],
Request#,
[Date Rqstd],

'Q' & Ceil(Month([Date Rqstd])/3) as Quarter,
MakeDate(year([Date Rqstd])) as [Year Requested],
[Primary Contact],
Priority,
[BPOC Relevant],
Requestor__,
Site,
[Yr Compl. a/o Closed],
ListID,
%Key_xml_98C49F546A18E856
FROM [Service.qvd] (qvd)
WHERE Year([Date Rqstd]) >= 2014 and Len(Trim([Date Rqstd])) > 0;

and now your Quarter field should most likely not have any Q's

View solution in original post

18 Replies
sunny_talwar

May be try this:

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

Not applicable
Author

it is complaining "As Quarter" error Garbage

sunny_talwar

Can you share the script?


pho3nix90
Creator II
Creator II

The must be something that isn't a proper date. If you want a workaround then you will be adding overhead into the calculation, rather sort the calendar out first in the ETL process.

Try this and see if it works.

'Q' & Ceil(Month(Trim([Date Rqstd]))/3)

Also have a look when selecting Q, which dates it links to.

Not applicable
Author

Hi,

here is the script

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

error message: Garbage after expression: "as"

Not applicable
Author

it links to no date, as it is Gray

sunny_talwar

Did you miss a comma at the end?

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

Not applicable
Author

No, I had the comma there.

sunny_talwar

Can you share the script for the whole table and a screenshot of the error you are getting?