3 Replies Latest reply on Feb 28, 2016 10:34 PM by Yuriy Fal

    My sort function doesn't sort well

    Shahirah Badrus



      I have a problem in sorting my blended data. Firstly, I've got two different data that been blended by its primary key. I want to do an analysis about top 10 customer, and I followed a tutorial Create Sets for Top N and Others | Tableau Software and it works well. Big thanks for this tutorial. After I've blended with another data, problem came. For example, Data A is the primary source and data B is the secondary source. In data A, I only use Customer name and number of records. In data B, I use state as a filter. Then, I want channel name to be sort by sum(number of records). As I try to sort, with some state has been filtered, it does not sort like I want to. It turns out the customer name being arranged randomly(?), I guess. Here I've attached the photo for my analysis.



        • 1. Re: My sort function doesn't sort well
          Yuriy Fal

          Hi Shahirah,


          Regular filters on fields from Primary datasource apply before

          any filters on (dimension) fields from Secondary datasource(s).


          So in your case a TopN filter from Primary applies first,

          and a filter on States from Secondary applies after that.


          So the only rows that belong to the TopN customers goes from Primary,

          and the only ones that belong to the filtered States are then aggregated

          into final number of Marks on a view, hence the result.


          It is usually better to use most (if not all) Dimension filters

          from Primary only, if possible. One could put some of them

          in Context -- to be applied before other "regular" filters,

          including TopN ones.


          Hope it could help.




          2 of 2 people found this helpful
          • 2. Re: My sort function doesn't sort well
            Shahirah Badrus

            Hi Yuri.


            Thanks for your guide. It helps! But there is something that I need to understand more.


            Certain of the customers name fall into OUT set even though it has a higher number of records. For example:


            Customer A - 100

            Customer B - 90

            Customer C - 50

            Customer D - 75


            After sorting them, and apply some filter, Customer A to C is in the IN set but D is in the OUT set. Suppose that Customer D should be in the IN set, while Customer C should be in the OUT set. Can you help me by explaining this?

            • 3. Re: My sort function doesn't sort well
              Yuriy Fal

              Hi Shahirah,


              I suspect that you've placed both TopN filter/Set

              and other "regular" (Dimension) filter(s) on Filters shelf.


              Since they all (both Dimension and TopN ones)

              have equal priority and applied independently of each other,

              Marks on a view are filtered in such a fashion:

              "Filter Dim_a"  AND "Filter Dim_b" AND "Filter TopN_by_Measure_c" -- and so on.


              To give some filters a priority, one could make them Context ones.

              If you put Dimension filter in Context, it is applied before any others,

              so your TopN filter/Set is applied after, and you would give the "correct" view.


              Please try to put all your dimension filters to Context, and leave your TopN one as such.


              Hope it could help.




              1 of 1 people found this helpful