8 Replies Latest reply on Jul 9, 2013 3:03 AM by Polagani Bhaskar

# 2 different date types on 1 axis

Hi,

Wondering if it it is possible to have 2 different date types on 1 axis. For example, on the x-axis,

_______________________________

Q4          Jan-12     Feb-12      Mar-12

Could this be done?

• ###### 1. Re: 2 different date types on 1 axis

You could create a calculation along the lines of

if date is last year then str(datetrunc('quarter',[Measure]) else str (datetrunc('month',[Measure])

• ###### 2. Re: 2 different date types on 1 axis

But this is giving me 01/012012......10/01/2011,

I want the word Q4, then Jan-12, Feb-12...and then field is a string field, which I cannot use on a graph(ie..line,bar)

• ###### 3. Re: 2 different date types on 1 axis

Hi Alan,

You could use Alex's calculation but changing the if then slightly so it would look similar to the following:

'Q' +str(datename('quarter', [Order Date]))

else left(str(datename('month', [Order Date])),3) + '-' + str(datename('day', [Order Date]))

-Tracy

• ###### 4. Re: 2 different date types on 1 axis

Thanks Tracy, so I guess theres are no other ways that I can get it onto a chart?

• ###### 5. Re: 2 different date types on 1 axis

You can create a line even if you have discrete measure. What you want to show is more difficult but would be along the lines of

if date is last year then "Q" + str(datepart('quarter',[Measure]) else str (datepart('month',[Measure])) +  str (datepart('year',[Measure]))

To get Jan, Feb as words, you would have to do another if then replacement because there is no text() or format() function you can use

• ###### 6. Re: 2 different date types on 1 axis

Calc (with datename - thanks Tracy, never used that)

if datepart('year',[Order Date])<2012 then

"Q" + str(datepart('quarter',[Order Date]))+" "+str(datepart('year',[Order Date]))

else str(datename('month',[Order Date]))+" "+str(datepart('year',[Order Date])) end

• ###### 7. Re: 2 different date types on 1 axis

Oh wow thats amazing Alex, Thank you!!

• ###### 8. Re: 2 different date types on 1 axis

Hi

Try this way u will get 75% problem solved.

'Q' + str(DATEPART('quarter',[Date] ) ) + '   ' + str(DATEMONTH('month',[Date] ) )+ ' - ' + right(str(DATEPART('year', [Date] )),2)