19 Replies Latest reply: Nov 26, 2015 4:48 AM by Sangram Reddy

# Quarter in line graph

hi all,

I need to display the line graph for quarterly. Last 4 quarters.

quarter name should be 3/31, 6/30, 9/30 and 12/31 of every year.

Now presently running last quarter so it should show from last quarter of last year and 3 quarters of this year.

How can i achieve this.

Thanks,

Kumar

• ###### Re: Quarter in line graph

Hi,

We can achieve this in two simple ways.

We can create a calendar or month/3 as dimension and have a if condition to restrict latest 4 quarters.

• ###### Re: Quarter in line graph

I will get the quarter if i use the below script:

'Q' & Ceil(Month(CanonicalDate) / 3)  AS Quarter,

I will get as Q1,Q2,Q3,Q4.  how can i get it as 3/31, 6/30, 9/30 and 12/31, last day of last month with last month in the quarter.

• ###### Re: Quarter in line graph

Hi,

Try like this

Month(QuarterEnd(DateFieldName)) & '/' & Day(QuarterEnd(DateFieldName)) AS Quarter_End_Date

Regards,

jagan.

• ###### Re: Quarter in line graph

Hi

Have a look with quarterend function in Qlik help

try this expression :

date(quarterend(CanonicalDate),'MM/DD')

give this in e textbox

Bruno

• ###### Re: Quarter in line graph

I am using below dimension and measure

Dimension:  date(quarterend(CanonicalDate),'MM/DD')

Measure:

Count({\$<DateType = {invitation},

CanonicalDate = {">\$(date(Quarterend(Max(CanonicalDate),-3),'MM/DD'))<=\$(date(Quarterend(Max(CanonicalDate)),'MM/DD'))"}>}invitation_id)

It's not showing all quarters instead of last 4 quarters

• ###### Re: Quarter in line graph

May be like this : ( Note the single quote around '>' and '<=' )

Count({\$<DateType = {invitation},

CanonicalDate = {"'>'\$(date(Quarterend(Max(CanonicalDate),-3),'MM/DD'))'<='\$(date(Quarterend(Max(CanonicalDate)),'MM/DD'))"}>}invitation_id)

Not sure it will work , I'am newbee in set analysis .

Bruno

• ###### Re: Quarter in line graph

No, That's wrong we should not use single quote like that

• ###### Re: Quarter in line graph

Hi Pramodgc3

As per your code it would only return 4 dimmension values for each year. Instead as Jagan guggested use :

Dimmension as "Month(QuarterEnd(DateFieldName)) & '/' & Day(QuarterEnd(DateFieldName))" and you respective measure.

• ###### Re: Quarter in line graph

If i use like above i'm getting all the quarters value, means for dec/31 it's showing from all the year,

what i need is last 4 quarters, means dec/31/2014, mar/31/2015, jun/30/2015, sep/30/2015

• ###### Re: Quarter in line graph

Hi promodgc3,

I have replicated what you need and attached the sample qvf. Only the rolling years quarters are shown up always.

- Sangram

• ###### Re: Quarter in line graph

Hi sangam Reddy,

Eventhough it restricts to 4 quarters, my requirements is not as you shown,

As this quarter is still not completed i need a last 4 quarters,

Means dec/31/2014, mar/31/2015, jun/30/2015,sep/30/2015...

not last quarter of 2015

• ###### Re: Quarter in line graph

Hi Pramodgc3,

This way you can get only the last 4 quarters, but not considering this quarter:

- Sangram

• ###### Re: Quarter in line graph

once the dec/31/2015 is completed the last 4 quarters will be changed right?

• ###### Re: Quarter in line graph

Hi promodgc3,

Your first variable in the 'IF' statement was NULL, hence this error. Check the date formats once or it would be easy if you attach a sample qvf. I will fix it for you.

once the dec/31/2015 is completed the last 4 quarters will be changed right? - Yes it will absolutely work. On 1st of Jan 2016, its going to show Mar/31/2015, June/30/2015, Sep/30/2015 and Dec/31/2015

• ###### Re: Quarter in line graph

Hi Sangram,

Thanks i fixed, how to sort the quarters as it must display in order...

• ###### Re: Quarter in line graph

Hi,

Try like this

*,

if(Last4Quarters = 1, Date(QuarterEnd(Date), 'M/D/YYYY') ) AS Quarter

FROM DataSource;

Hope this helps you.

Regards,

jagan.

• ###### Re: Quarter in line graph

Hi jagan,

You check the first sheet in attached app.

It showing 5 quarters and also not in order help on it.

• ###### Re: Quarter in line graph

Hi Promodgc3,

So for sorting purpose, just change the expression to :

if(Last4Quarters = 1, Date#((Day(QuarterEnd(Date)) & '/' & num#(Month(QuarterEnd(Date)))& '/' & year(QuarterEnd(Date))), 'DD/MMM/YYYY'))

and sort it using the sorting pannel:

This should solve the sorting issue