Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
benjamins
Partner - Creator
Partner - Creator

Problem sorting dimension with generated dual date

I'm using a dual Year&Week as the only dimension of a bar chart (see attachment).

I load Year&Week in script as

Dual(Year(DateId)&' '&Week(DateId),WeekStart(DateId)) as YearWeek

DateId is a plain date

I set the dimension's sorting order to numeric ascending as I would have expected the numeric value of the dual YearWeek to be used. However this does not seem to be the case as the result is:

2012 52

2012 1

2012 2

2012 3

...

2013 51

2013 52

2013 1

When loading years 2012 and 2013.

I've tried lots of different approaches from using other sorting orders up to interpreting YearWeek as string only. None of which yielded a correct result.

Anyone any idea what I'm overlooking?

Thanks and cheers

Benjamin

11 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

Try with this

Dual(Year(DateId)&' '&Week(DateId),Num(Year(DateId)&Num(Week(DateId),'00'))) as YearWeek,

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     I guess nothing is wrong in your sorting, only thing is the year field which you have created is wrong.

     Let me give you an example.

     You have written

     Dual(Year(DateId)&' '&Week(DateId),WeekStart(DateId)) as YearWeek,

     So now consider the date 01.01.2012.

     The week for this date is 52 (which is of last year i.e year 2011) but in your field it shows as 2012 52, which is wrong, correct is 2011 52.

     So change your expression to.

     Dual(Year(weekstart(DateId))&' '&Week(DateId),WeekStart(DateId)) as YearWeek

     Hope this is clear to you.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!