3 Replies Latest reply on Dec 12, 2018 8:22 AM by Michael Elser

    Sort Order not respected in consolidated E-mail

    Michael Elser

      Hi,

       

      I'm 99% done with an important report. The only problem is that the rows don't come out sorted!

       

      In Tableau all looks fine:

       

      1.png

      I want to sort alphabetically by the Product Category (Adenovirus -> Agarose -> Antibody -> cDNA) as shown above.

      The temporary CSV generated by VizAlerts looks good as well:

       

      2.PNG

      All sorted well and the consolidated sort order is present.

       

      But in the log file, you can see that the order has suddenly changed, even though all the field names seem to be detected correctly:

       

      3.PNG

      "Antibody" was lost somehow and is now near the bottom of the consolidated mail.

       

      Has anyone successfully used consolidated sorting?

       

      Best regards,

       

      Michael

        • 1. Re: Sort Order not respected in consolidated E-mail
          Matt Coles

          Hey Michael, would you mind sharing the CSV, with sensitive info removed? I'll see if I can repro and fix it.

          • 2. Re: Sort Order not respected in consolidated E-mail
            Matt Coles

            Michael, the issue is that VizAlerts is treating your Consolidated Sort column as text, rather than as a number, so it is sorting alphabetically. Therefore "10" comes directly after "1", then "11", and so on. I'd recommend ensuring that your Tableau workbook is treating that field as a string, and prepending "0" to anything below 10 to ensure the right sort order.

             

            And, for what it's worth, the docs do mention this...

             

            From VizAlerts/user_guide.md at master · tableau/VizAlerts · GitHub

             

            When we’re using consolidated alerts, we often want the content to be generated in a specific order within each email. The Sort Order field lets us do that. When it is present, the values in the field are used to alphanumerically sort each row in the trigger view for each email or SMS. Here’s an example setup from the VizAlertsDemo\AdvancedAlertsTests worksheet:

             

            Don't feel too bad, I had forgotten it works this way too. Doesn't help that the demo uses numbers for sorting, either. And this happens often enough that I think it's probably worth writing a little code to auto-detect if only numerical values are used, and sorting numerically if that's the case. Here's the issue I created to track this. Thanks for reporting! Let me know if you're able to implement the workaround to fix this.

             

            Matt

            2 of 2 people found this helpful
            • 3. Re: Sort Order not respected in consolidated E-mail
              Michael Elser

              Hi Matt,

               

              OK, that makes perfect sense, thank you. I tried to find a pattern in the resulting sort but did not think of the "1,10,11" problem.

               

              And yes, I found a workaround. I can't transform the number into a string in Tableau because I'm using it to get banded rows in the HTML table (basically using INDEX() % 2 to find out if it is an even or odd line and then inserting one or the other of the band colors into the table row element). That's the only way I found to get banded rows rendered correctly in Outlook.

               

              For the sorting I use another field now, namely the category field. So I created a new calculated field called "Sort Order" with UPPER([Category]) as a formula for a case-insensitive sort directly on the name of the category.

               

              Works great!

               

              Michael