VizWiz

Launch, grow, and unlock your career in data
Showing posts with label datediff. Show all posts

September 2, 2022

5 Most Common Date Functions in Tableau

No comments

In this tip, I take you through the 5 most common date functions in Tableau:

  1. DATEPART
  2. DATENAME
  3. DATETRUNC
  4. DATEADD
  5. DATEDIFF

By the end of this video you will understand when to use them to meet your use case. Click here for the cheat sheet I created for these date calculations.

July 21, 2021

How to Compare to the Prior N Months Using the IN Function

No comments
This tip comes from an exercise I did alongside DS21 to find different ways to compare to the prior 3 months. Owen Barnes came up with the method using the IN function upon which this tip is based.

Check out how we did this same exercise with a table calculation and a level of detail expression on Owen's blog here.

June 7, 2018

Workout Wednesday: How does sales compare in the Current Period to the Previous?

No comments
It's been eight weeks since I've done Workout Wednesday. Sometimes you have to reprioritize things to get other things done. For me, WW was something I could cut out to free up more time for finishing the Makeover Monday book (pre-order here).

But I'm back and this week Rody gave us this challenge. Read all of the requirements here.

I had an idea straight away how to do this and in all it took about 30 minutes. The date offsetting took some tinkering, but the rest was pretty easy. I'm glad Rody is back from his hiatus too. His challenges aren't as brutal as Ann's.

Click on the image for the interactive version.

March 14, 2017

Tableau Tip Tuesday: Using LODs to View the Latest, Previous and Prior Months

16 comments
This week's tip comes from a question on The Information Lab's collaboration platform about returning the latest, previous and prior month values.

I'm using LOD expressions in this video along with the DATEDIFF and DATETRUNC functions. Below this video, you will see the calculations that I used if you want to copy/paste them for your own use.


Latest Month Sales

IF DATEDIFF('month',DATETRUNC('month',[Order Date]),{MAX(DATETRUNC('month',[Order Date]))})=0
THEN [Sales]
END

Previous Month Sales

IF DATEDIFF('month',DATETRUNC('month',[Order Date]),{MAX(DATETRUNC('month',[Order Date]))})=1
THEN [Sales]
END

Prior Month Sales

IF DATEDIFF('month',DATETRUNC('month',[Order Date]),{MAX(DATETRUNC('month',[Order Date]))})=2
THEN [Sales]
END

If you want the months to be labeled…


Latest 3 Months

DATEDIFF('month',
DATETRUNC('month',[Order Date]),
{MAX(DATETRUNC('month',[Order Date]))}) <= 2

Latest N Months

DATEDIFF('month',
DATETRUNC('month',[Order Date]),
{MAX(DATETRUNC('month',[Order Date]))}) < [How many months?]