12 Replies Latest reply on Sep 10, 2018 12:23 PM by Meg Dingmann

    How to show list of values in Tooltip in Highlighted Bar from Chart

    Theresa Vu

      Hi,

       

      I work at a hospital and want to use the tooltip function in a bar chart. I'm working on a bar chart of patient mortalities, complications, volumes, etc and I'm using a bar chart to showcase my data. For presentation purposes, I want it to be more interactive, so if I show a chart that has number of complications for a period of time, I could hover over a bar and the tooltip will populate the patient names that had these complications during a procedure for that particular bar which is from a timeframe. I followed Jonathan Drummey's post http://public.tableau.com/profile/jonathan.drummey#!/vizhome/shared/QKHTZGBKP and noticed that when I hovered over a bar all patients in the chart would be listed even though my chart clearly noted there was only one patient with that complication for that month I was hovered over.

       

      Thank you!

      Theresa

        • 1. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
          Joe Oppelt

          You're going to have to upload a workbook.

           

          You're following the right template if you're doing the method in Jonathan's example.  But somewhere in all the machinery you're going to have to add in logic to exclude names that don't fit the criteria for that mark.

           

          The PREVIOUS_VALUE function is a table calc. It traverses the whole table.  You want to look at what conditions you want to include in the final output string.


          It might just be a matter of specifying a RESTART on the table calc.  But without a concrete example, I can only guess.

          • 2. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
            Theresa Vu

            Sadly, because I work at a hospital, all our information is confidential. I'll have to create a sample worksheet that simulates my problem.

            • 3. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
              Joe Oppelt

              Here's what I did.  I took Jonathan's example, deleted all the other sheets.  I put a filter on the sheet to exclude any rows for "Furniture" AND "Small Box" so that we would have differing contents from Department to Department.  I had that workbook saves as 8.2, so I just did this work in 8.2 as well.  It will upgrade to whatever version you need.

               

              I changed the two table calcs to RESTART for every Department.

               

              (As it turns out, "Office Supplies" doesn't have any blue (Jumbo Box) so I really didn't need the filter.)

               

              Now, you get in tooltips only the list of containers for that particular Department.

               

              You'll want to do a similar thing in your workbook.

              • 4. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                Theresa Vu

                Hi Joe,

                 

                Thanks for sending that but I'm fairly new to Tableau and don't really understand what you did... How did you change the two table calcs to RESTART for ever department??

                 

                Attached is my sample workbook so you can see what I'm dealing with.

                 

                Thanks!

                Theresa

                • 5. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                  Joe Oppelt

                  You have to upload a twbX file.  Do FILE --> "Export Packaged Workbook"   to make a twbX file. 


                  And let me know what version you are using.

                  • 6. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                    Theresa Vu

                    Woops, I meant to save it as a packaged workbook. Sorry!

                     

                    The version is 9.1

                    • 7. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                      Joe Oppelt

                      This is going to take some additional work.  One thing that differs between your sheet and Jonathan's is that you don't have [Pat L Name] on the sheet, which is what you need to cycle through.  I'll have to look at this tomorrow.

                      • 8. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                        Joe Oppelt

                        Jonathan Drummey -- am I correct in assuming that to cycle through a dimension in the underlying data for making the string list using PREVIOUS_VALUE (sheet 15 in "The Next N Table Calcs") we have to have the dimension in question on the sheet?

                         

                        In trying to get Theresa's sheet to work, I put Name on the sheet.  (If this is the route she'll have to go, we can get the viz we need with table calcs and INDEX=1 in the filter.)  But I simply cannot discern the proper table calc settings to get counts of 1-n in each bar.  Attached is a sheet (Sheet 7) after a million stabs at it.  If I can get 1-n, then I can also get INDEX=1 and pump out just one value and have the colors and all (half way there on Sheet 8).  Then I cam make the String List calcs cycle the same way, and off we go.


                        But I simply cannot make INDEX cycle correctly here.  I usually can get these to work, but not this one. 

                         

                        Any ideas?

                         

                        BTW, the workbook attached is 9.1.  I don't mind if you figure something out in 10.1 (if you no longer have 9.1.)  I can apply it to my 9.1 workbook for Theresa.

                        • 9. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                          Jonathan Drummey

                          Hi Joe,

                           

                          Something that uniquely identifies every encounter/case (such as the Case Number) should be on the worksheet for two reasons:

                           

                          1) As you surmised it's necessary to make the PREVIOUS_VALUE() calc work. If you want more details on the "why" of this I just put a bunch of details in another thread where the underlying principle is the same (needing to increase the vizLOD so a table calc can work): Re: Replicate VAR functionality through Script_real. We can hope that someday Tableau will give us an aggregate function that can concatenate across rows without having to jump through so many hoops.

                          2) Multiple patients can have the same name. (I live in an area with a lot of people of French-Canadian descent where many people have the same last name like Cote, Jacques, etc. so we saw this multiple times a year in the hospital). So we'd want to show John Cote twice two indicate two patients rather than just once if we used just the Name as a dimension.

                           

                          This increases the viz level of detail so your Index calculation isn't working as expected (though the compute using could be set appropriately) and the COUNTD() is returning 1 for each patient, and you're getting a mark for each patient. The ideal view has one mark per month/complication so the vizLOD (w/Case Number, Month, Quarter, and Complication) is not the desired displayLOD (which is really just Month, Quarter, and Complication). To make it all work here's what I did in the attached workbook:

                           

                          1) created custom dates for the quarter & month.

                          2) Created a workout view with the custom date dimensions on the Level of Detail Shelf and ATTR()'ed versions of those on Rows, along with the Complication Text & CaseNumber. The reason why I did that with the dates is to avoid complicating with Tableau's date densification behaviors (we can work around them with Advanced Compute Usings in our table calculations but I find creating custom dates much easier to build, explain, and maintain). Setting up the workout view this way enables me to see all of the addressing and partitioning and table calc results in an easier-to-debug crosstab view.

                          3) Added the Patient Name Tooltip, Index, and a new # of Patients calc using SIZE() as the formula to the view all with a Compute Using on the CaseNumber. SIZE() is a calculation that returns the number of addresses in a partition, so it acts like a COUNTD() for the partition. Here's the workout view:

                           

                          Screen Shot 2016-11-30 at 2.29.06 PM.png

                           

                          Then I duplicated this view and rearranged pills and turned off tooltips on appropriate pills (there's still some formatting to do on the dates):

                           

                          Screen Shot 2016-11-30 at 2.29.52 PM.png

                           

                          At some point we'll get the announced viz-in-tooltip feature and this will be much easier to create.

                           

                          In the meantime an alternative view that doesn't require any calculated fields or mucking around with table calculations abandon is entirely drag-n-drop would be to set up a simple bar chart w/out the casenumber/patient name in the vizLOD and then a separate tabular worksheet, put those two in a dashboard then set up a hover action, here I've hovered over the July 2015/CF mark:

                          Screen Shot 2016-11-30 at 2.35.16 PM.png

                           

                          Let me know if you have any questions!

                           

                          Jonathan

                          2 of 2 people found this helpful
                          • 10. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                            Joe Oppelt

                            Jonathan Drummey == You showed me something.  The key was the custom dates.  I was trying all sorts of combinations of compute-using and at-the-level with the original date fields.  Changing these pills to custom dates makes everything I was trying earlier work smoothly.

                             

                            Changing them to custom dates did the trick.

                             

                            Theresa -- See attached.

                             

                            Sheet 1 is your original.  Sheet 2 adds [L Name], and changes quarter and month to custom date calcs.  (Right click on [Day of Surg],choose Create, and then custom date.)

                             

                            Sheet 8 changes the COUNTD pill to a table calc.  (SIZE() tells us the number of rows in the bar.)  Right click on that pill in the text shelf.  Select EDIT TABLE CALCULATION.  You will see that I selected [L Name] for "Compute using".  That tells Tableau to run the calc along the [L Names] in the partition.  We will be using that same setting for every table calc we use in this example.  Notice that we're still getting multiple copies of the value -- one per patient in each bar.  We will distill that out later.

                             

                            Sheet 9 -- CTRL-Dragged my table calc from the text shelf to the colors shelf.  CTRL-drag keeps the original in place, but adds a copy to the new location.  This also preserves the table calc setting to run it along [L Name].  You'll see that the bars are now colored the same as you have in Sheet 1.

                             

                            Sheet 10 -- I CTRL-Dragged the calc to the ROWS shelf and placed it on top of the COUNTD pill that was there.

                             

                            Sheet 11 -- Here is where we make one value per bar.  The values that were in the multiple marks per bar are identical as I pointed out earlier.  We really only need the first one in each bar.  I created a calc [Index].  It is simply the INDEX() function.  I placed that on the filter shelf and clicked OK to the initial default.  then I changed that pill to run along [L Name] just like all other table calcs in this exercise.  When you make that change, Tableau asks you to select the value(s) you want.  Select for value = 1.  I do it by setting minimum and maximum to 1.  Now Tableau will show us only the first mark for each bar.  At this point we have essentially re-created what you had in Sheet 1, but accounting for [L Name] being on the sheet.

                             

                            Sheet 12 -- Drag the [... tooltip] calc to the tooltip shelf.  Right click on the pill and select Edit Table Calc.  This part is a little tricky.  Select [L Name] for Compute Using.  Then, at the top of this dialog box you will see a pulldown set to [Patient Name Tooltip],  You don't have this pulldown on any of the other table calcs, but it is here because this table calc is based on another table calc.  Pull down and select [... Feeder].  You need to set this calc too.  Again, set Compute Using to [L Name].

                             

                            Now look at the tooltips.  This was the result I was aiming for last night.  I knew it would work, but it took Jonathan to unlock the key to making it work.

                             

                            And after having explained all that, I want to make sure you look at the dashboard in Jonathan's example. It is another way to address the visualization you wanted to achieve, and it's rather elegant.  Rather than putting the names into tooltips, it displays a whole other sheet that pops up as you scroll over any bar.

                            1 of 1 people found this helpful
                            • 11. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                              Theresa Vu

                              THANK YOU, Joe Oppelt and Jonathan Drummey! This was very helpful for a newb like me. Jonathan's example is definitely more than I could have imagined and will be helpful for our presentation.

                              • 12. Re: How to show list of values in Tooltip in Highlighted Bar from Chart
                                Meg Dingmann

                                Hi Joe,

                                Thank you so much for your fabulous example outlining how to view specific data in the tooltip and in a list format. Using your directions, I was able to do this in my own data set. However, I ran into a snag when I wanted to change my bar graphs to percentages rather than counts.

                                 

                                Would it be possible to view the data in the tooltip and in the list view (Tooltip Problem Example X.twbx) but see the bars as percentages rather than count?

                                 

                                Kind regards,

                                Meg