Showing posts with label datediff. Show all posts
September 2, 2022
5 Most Common Date Functions in Tableau
add
,
calculated field
,
compare
,
date functions
,
dateadd
,
datediff
,
datename
,
datepart
,
dates
,
datetrunc
,
difference
,
tableau
,
tip
No comments
In this tip, I take you through the 5 most common date functions in Tableau:
- DATEPART
- DATENAME
- DATETRUNC
- DATEADD
- 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
% difference
,
calculated field
,
change
,
comparison
,
datediff
,
datetrunc
,
function
,
IN
,
latest
,
level of detail
,
LOD
,
prior
,
prior 3 months
,
tableau
,
tip
No comments
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?
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.
Click on the image for the interactive version.
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.#WorkoutWednesday Week 23: How do Sales compare in the current period to the previous.— Rody Zakovich (@RodyZakovich) June 6, 2018
Giving a slight twist on some older challenges. Enjoy!https://t.co/gBn05E4gev@lukestanke @AnnUJackson pic.twitter.com/trqc3ZnT3G
Click on the image for the interactive version.
March 14, 2017
Tableau Tip Tuesday: Using LODs to View the Latest, Previous and Prior Months
datediff
,
datetrunc
,
latest
,
level of detail
,
LOD
,
previous
,
prior
,
Tableau Tip Tuesday
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.
THEN [Sales]
END
THEN [Sales]
END
THEN [Sales]
END
DATETRUNC('month',[Order Date]),
{MAX(DATETRUNC('month',[Order Date]))}) <= 2
DATETRUNC('month',[Order Date]),
{MAX(DATETRUNC('month',[Order Date]))}) < [How many months?]
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]))})=0THEN [Sales]
END
Previous Month Sales
IF DATEDIFF('month',DATETRUNC('month',[Order Date]),{MAX(DATETRUNC('month',[Order Date]))})=1THEN [Sales]
END
Prior Month Sales
IF DATEDIFF('month',DATETRUNC('month',[Order Date]),{MAX(DATETRUNC('month',[Order Date]))})=2THEN [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?]
Subscribe to:
Posts
(
Atom
)