Data Viz Done Right

January 5, 2016

Tableau Tip Tuesday: Using LOD Calcs to Sort by the Total of the Last N Days

LOD expressions are still a bit of a mystery to me. I haven't had the "Aha!" moment yet when they magically click in my head. I am continuing to learn more and more about them and this week, I share a tip with you that allows you to sort a dimension by the total of the last N days picked by your user.

If anyone knows a better or more efficient way to do this, please share!


  1. Andy, thank you!

    Please, why we should use Min function to wrap IF statement?

  2. Cool trick! You requested, so I played with this and changed the calc to: {INCLUDE: SUM(IF [In Last N Days?]=TRUE then [Sales] END) }. The include makes it responsive to whatever you have within your view and allows you to sum like normal. Putting the calc inside the aggregation filters it only to the last N days. I ran a few spot checks and it seems to work.
    My crazy takes on LODs are and!/vizhome/THEFORCEAWAKENS-LODVersionCTUGPresentation/LOD. Please let me know if either of these help. Cheers.

    1. Awesome Bridget!!! Thanks for sharing and thanks for improving my work!