[Forward: I asked ChatGPT o1-mini who then wrote this. Hope it helps. All the credit and the blame go to ChatGPT.

I went over the plan and it looked decent. Whether it can be done in 30 days or not, it depends on the person and the time he spends on it.
Just came back from Tableau Conference 2022 at Las Vegas. What an exciting event! The most exciting thing is reuniting with old friends and meeting with the datafam people known online for years.

Attended first time the Tableau Visionary summit.
A little enhancement in the formula editor can make a big difference for whose who create formula all the time in Tableau. Here are my wishes for a future editor. 

Highlighting Syntax Words

Currently a formula in Tableau can look plain and a bit uninspiring.

For the sake of uniformity in a bar chart, we may need to filter out dates in the latest partial week, month, quarter or year. That is what Parinita asked me about a filter to do just that.

How to design a filter for it? Especially, we need the design to take into consideration of dynamic date range which can be changed by the user.

Here we will show two approaches to it. They differentiate themselves by the order of filtering. Note that we will use a parameter Date Grain to denote the selected date period. A grain can be any of day, week, month, quarter and year. We will use the superstore data set to create examples.

1. LOD Approach

This is a pre filter approach. It will remove the data rows in the partial period before calculations. With LOD calculations, we must add the date range filter to the context.

Here is the Date by Grain:

First we get the max date of the data set

Then we have the filter as follows. Select true to remove the partial period.

2. Table Calc Approach

This is a post filter approach. It will remove the calculation results belonging to the partial period. This post filter is always second to date range filter which doesn't have to be in context.

For Date Grain, we will need to use the aggregate form:

Same as above, we need to first calculate the Max Date of the data set. 

Thus we use Window_Max() to calculate it which is available everywhere. Note that we need to set it up to compute along Date by Grain.
The resulting filter is as follows:

Postscript

The LOD approach seems a little simpler. However we have to be very careful about the context. It may go wrong if we don't set the context filter correctly.

The Table Calc approach will work regardless of context. The table calculations require setting up along the date dimension carefully. 

In most cases, there is a solution via LOD and also an equivalent solution via table calculations. Pick the one that you feel most comfortable about.

A demo workbook can be downloaded here

Feel free to leave comments below or contact me at twitter: @aleksoft

0

Add a comment

Blog Archive
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.