2 Replies Latest reply on Feb 14, 2019 12:21 AM by cyu cc

    Issues with SET operation

    cyu cc

      Hi all, I met a question when making a chart with my data. The data is packaged in the attached twbx file. The data simply describes the sales record. My purpose is to make a chart to show the distinct seller count of each item, only shows the top 3 item, all the other items are showed in one bar named “Others”, and the “Others” bar should always be the last bar. I use a SET to filter the top 3 items.


      Now open my workbook and the default view chart looks like this:


      Uncheck the sdate “2018/12/18” in the filter, then the chart becomes:


      Check the sdate “2018/12/18” and the chart reverts to the original state.


      Everything seems OK.


      Now import the source data to a PostgesSQL or Greenplum database. Create a new data source via connect to the database, replace the data source, the chart becomes:


      The second bar changed from P3 to P4. In fact, the measure value of P3/P4/P5 are the same (8), so here comes the first question: Why the sequences are different with different data source?


      Now uncheck the sdate “2018/12/18” in the filter, then the chart becomes:


      The “Others” bar is moved to the third place. This is not the correctly result we want. And logically this should not be the final result. Now refresh the data source, the chart is correct again:


      So this is the second question: Why a refresh of data source (source data not changed) can cause a different chart?


      I’ve tried to import the data to SQL server database and do the same test. The sequence of P3/P4/P5 is different from the former two cases (when use CSV data source, the sequence is P3-->P5-->P4, when use PostgesSQL/Greenplum data source, the sequence is P4-->P5-->P3, when use SQL server data source, the sequence is P3-->P4-->P5). Uncheck the sdate “2018/12/18” can get a correct result.

        • 1. Re: Issues with SET operation
          Patrick Van Der Hyde



          The first question relates to p3 showing up in others.  This appears to be because it has the same number of values as other pvalues but i believe the cause is that it appears later in the data rows than p4 and p5 - (view data indicates p4 and p5 show up before p3). 


          The values change with the date filter because it is set to 'context' so the top 3 is being calculated higher in the order of operations and causing the set to include the consideration of p3 with it's 8 values as part of the set. 


          You can learn more about the order of operations here - Tableau's Order of Operations - Tableau


          I hope that helps



          • 2. Re: Issues with SET operation
            cyu cc

            Hi Patrick,

                 Thanks for your reply. I'm not sure if the appearance sequence causes the result, if so, P5 should be the first one of (P3,P4,P5) because P5 first appears in second row (the first row is P1). Even this is the real cause, I think it is not good enough. The better way should be allow users to specify another field to compare when first field have same values. You mentioned the order of operations, I did have studied it, the document describes that context filters are processed prior to TOP N filters. It seems it is not the same with what you said ("the top 3 is being calculated higher in the order of operations").