Recently while
creating one of the Tableau Dashboards I met with an issue where the column values order in
tableau was not similar to our data source order.
As soon as data was coming to tableau it was changing the
sort order to ascending or descending. when I did some research about the issue
in tableau forums, I came to know that you cannot just keep the same order from your data source.
Therefore I came up with the
workaround which anyone can apply if they came across with similar issue.
Below I will first
Re-Produce the issue using the below data source.
Student
|
Marks
|
RM
|
2
|
NB
|
4
|
PA
|
4
|
CM
|
4
|
CS
|
4
|
GI
|
4
|
PS
|
3
|
CA
|
3
|
RT
|
4
|
RA
|
4
|
HR
|
3
|
ERM
|
4
|
DG
|
3
|
GBA
|
3
|
If you will notice in the
above table RM is the first Student so I was expecting the same order my Graph.Now I am using above table
as my Tableau data source to create a bar chart report on this as below.
After plotting the Student
and Marks in the plot I found that the data order has been changed from its
original data source sort order, If you will see in the bar chart CA is coming
first then CM then CS then DG whereas our actual sort order was RM, NB, PA and
so on.
Based on the above it was
understood that after connecting to Data source the we were loosing the actual sort
order in Tableau Report
To fix this issue one way
is to Right click on Columns where we have placed our student dimension click
on Sort and manually sort the order as below. This will work perfectly fine
without any issue.
But think of my scenario
where i was having multiple sheets like this and was having multiple of column values
in it. So, if we will go with above solution like going to each sheet and apply the manual sorting and again and you have around 100 plus values in your
column then it will be a time consuming hectic task.
So below is the best way
to retain the original Data source order in your tableau Report.
You can add a Rank or Row
Number column in your data source as below
Student
|
Marks
|
Rank
|
RM
|
2
|
1
|
NB
|
4
|
2
|
PS
|
4
|
3
|
CM
|
4
|
4
|
CS
|
4
|
5
|
GI
|
4
|
6
|
PS
|
3
|
7
|
CA
|
3
|
8
|
RT
|
4
|
9
|
RA
|
4
|
10
|
HR
|
3
|
11
|
ERM
|
4
|
12
|
DG
|
3
|
13
|
GBA
|
3
|
14
|
Now refresh your data
source and just click on sort and in
sort by select Field and Select Rank from there click apply and you will
notice that your bar graph will have similar order as of your data source.
Now you have any no. of sheets or any no. of values in your column just you have to add a new column with Rank and sort the data based on this Rank.