# A Deeper Look at LOD Expressions—Week 2

February 23, 2015

In today's post we will continue to discuss Level of Detail (LOD) Expressions. Since it is often easiest to learn through examples, we will showcase some common analytical questions that LOD Expressions solve elegantly. We will start with simple examples and get progressively more complex throughout the series.

Why is this important?
LOD challenges arise everywhere and whether you realize it or not there is a very good chance you have run into them before. LOD Expressions allow us to fix a calculation to a specified dimension so that it will always compute at that level of granularity. You can think of it as a hidden shelf to put dimensions.

Who are LOD Expressions for?
Have you ever asked a seemingly simple question of your data and not been able to find a useful solution? Have you ever found yourself creating a complex workaround to those simple
questions? Then it’s very likely you have experienced an LOD related challenge.

LOD Expressions take Tableau's computational capabilities to the next level and both eliminate the need for many cumbersome workarounds and enable use cases that were previously not possible. After a little bit of practice everyday business users can use LOD Expressions to amplify their ability to see and understand data.

Let’s look at LOD expressions in a few real examples:

Histogram of Orders
Finding the number of times each customer made an order from our stores is an easy task. What if we want to know the number of customers who made 1, 2, 3 or 4 purchases in total? This is a simple question, but without LOD Expressions the solution would be difficult. The order data in this example has multiple items per order, therefore we cannot just make a histogram from the count distinct of orders. We need to find a way to always set the distinct count of orders to the customer dimension.

Daily Profit KPI
We can certainly view profit trends over time, but what if we measured our success by the total profit per business day? We would probably want to know the number of profitable days achieved each month or year, especially if we were curious about seasonal effects. The following workbook shows how LOD Expressions allow us to easily create bins on aggregated data such as profit per day rather than profit per transaction.

Comparative Sales
LOD Expressions open up a world of possibilities for cohorts, aggregates of aggregates, aggregated bins and many more areas. They also open doors to less obvious, but equally
valuable use cases such as comparing a section of our regions/items/employees to all others. The following example walks through how to compare a selected category to all of the other peer categories, which makes it easy to see how they are doing relative to each other.

Submitted by Frank Buckland (not verified) on

These are pretty cool visualizations , but I have a question. In the Daily Profit KPI graphs, I accidentally double-clicked on the graph and it disappeared. I couldn't figure out what was going on. Is this a feature, or is there a glitch somewhere?

Submitted by Shawn Ashmore (not verified) on

Frank, not sure if this is your issue, but I can make the graph disappear when double-clicking a part of the graph that is not populated with data. What is actually happening is that I am zooming in on a small range of the graph that has no data, thereby "fixing" the axis to a narrow range. If you see the "house" or "home" icon in the upper left of the graph, click it to see if the graph is restored. Regards.

Submitted by Frank Buckland (not verified) on

Thanks, Shawn. I think I see how this is working now and I see there are several ways to restore the original view. But I'm not seeing how zooming is helpful in these graphs, especially in the KPI line chart I was looking at. In cases where zooming would help clarify a relationship in the data, wouldn't it better for the user to have obvious tools and explicit instructions for zooming or sub-setting the data? It seems to me that the visualization's response to a double-click can easily confuse or annoy a user if they don't know what to expect. Well, at least that was my experience, but I could be an outlier. Again, thanks for your help.

Submitted by Jessie (not verified) on