VizWiz

Launch, grow, and unlock your career in data

May 9, 2017

Tableau Tip Tuesday: Using LOD Expressions to Color Lines By the Most Recent Value

2 comments
This week's tip came about when working through a question at the Data School during our client project last week. The question was essentially:

How can I color each line on a line chart by the most recent value?
This requires a three-pass LOD expression. The key is to realize that Tableau created an aggregate table for each LOD working from the inside out. So

  1. Tableau calculates the inside LOD first.
  2. Then the second LOD is calculated based on the results of the first LOD.
  3. Then the third LOD is calculated based on the results of the second LOD. 

Make sense? I hope so! If not, let me know. Enjoy!

2 comments :

  1. How is the following modification to your `Latest Sales` different?

    ```
    // For each region, calculate the maximum quarter
    // Then for each region, return the latest quarter of sales

    { FIXED [Region] :
    SUM(
    IF DATETRUNC('quarter',[Order Date])=
    {FIXED [Region] : MAX(DATETRUNC('quarter',[Order Date]))}
    THEN
    [Sales]
    END
    )}
    ```

    ReplyDelete
    Replies
    1. Great catch Brian! I do indeed have an unnecessary LOD in there. I've updated the viz. Thanks!!!

      Delete