By: Eric Parker
Eric Parker lives in Seattle and has been teaching Tableau and Alteryx since 2014. He's helped thousands of students solve their most pressing problems. If you have a question, feel free to reach out to him directly via email.
I’ve been working with a healthcare system that wants to do a better job of understanding patient behavior. Better understanding will drive decisions around staffing, purchasing, shift breaks, essentially the entire way the system is managed.
One of the questions they are looking to answer is, “How frequently do patients visit our system?” They’d like to know what portion of their population only visits once per year and how many visit 10+ times per year.
In this data set, each visit is listed as a single row of data.
To answer this question, I’m going to filter a worksheet down to the year in question and put a unique count (COUNTD) of patients that visited that year on Rows to create a vertical bar.
Now, I’d like to learn how many of those 366 patients visited just once, how many visited twice, etc. Unfortunately, there is no field called “Visits Per Patient”. In order to calculate visits per patient, I’m going to use a FIXED level of detail expressions which allows us to pre-calculate the number of visits at the patient level.
The [Visits Per Patient] calculation can now be converted into a Dimension in the data pane and then placed on the Columns shelf to generate the visit count labels.
This visual generally seems right, but if we look at it critically, we might have some concerns. For instance, were there really multiple people that visited the hospital 194 times in 2018?
The issue we are seeing is that the visit counts in the labels reflect the all-time number of visits per patient, not just the number of visits in 2018. That’s because FIXED level of detail expressions ensure that values are aggregated before standard dimension filters.
What we need to do is add the 2018 filter to context.
Once that’s done we have an accurate chart showing us how many times patients visited our system in 2018.
Want to learn more about Level of Detail Expressions in Tableau? Join us for our webinar next week, Unraveling the Mystery of Tableau Level of Detail Expressions!