4 Replies Latest reply on Jul 26, 2016 7:47 AM by Ashish Aggarwal

sorting data in a dimension in tableau

I am using tableau 8.2 and I have a dimension ( String format) containing date in 2 formats.  Below is the sample data. Now I am using this dimension in filter and want to sort the values.

Is there any way to sort the bold data as per the dates ?

date

Mar16

Apr16

Apr15

Jun15

Jan15-Dec15

Jul15-Jun16

Thanks for you help

• 1. Re: sorting data in a dimension in tableau

Ashish,

Let's go Step by Step.

[Left 3]  // Month by 3 digit string

left([Date],3)

[Right 2]  // Day by 2 digit string

right([Date],2)

Convert above two to 2016's dates.

[Date Calculated]

date(DATEPARSE("d.MMM.yyy",[Right 2]+"."+[Left 3]+"."+"2016"))

[Date Calculatd 2]

if not contains([Date],"-") then [Date Calculated] end

Thanks,

Shin

8.3 attached.

• 2. Re: sorting data in a dimension in tableau

Hi Shin,

The format is Month and Year , so its like Apr16 ( Apr 2016).  Another thing is that I cannot distort the format, these needs to be like this but only in a sorted way .

I am ok If we are not able to sort the format ( Apr15-Mar16) but needs to sort the format ( Apr16).

Thanks,

Ashish

• 3. Re: sorting data in a dimension in tableau

OK, Change the formula

[Date Calculated]

date(DATEPARSE("d.MMM.yy","1."+[Left 3]+"."+[Right 2]))

and Put the field left to original "Date"

and sort with [Date Calculated]

Thanks,

Shin

• 4. Re: sorting data in a dimension in tableau

Hi Shin,

Thanks for the solution. Its working when I am trying to get the values on sheet.

But I am using the date column in filter ( single value dropdown) and there it should show the value in sorted manner.

Thanks,

Ashish