Tableau Fixed Max date registered by month - tableau-api

I want to create a graph line in tableau with a count distinct id per month.
I use an excel spreadsheet that is updated a few times per month but never on the same date, so I have different dates registered as months go by.
I want to use the last date registered per month so I can use that date to show month's trend through the years. Each id represent a different construction building, so it is expected that the same id can be found on different months.
This is what I tried: Tableau Fixed (LOD) formula the get last date registered per each month:
{ FIXED [id_constructionbuilding], MONTH([date_registered]): MAX([date_registered])}
Then I use rows and columns in tableau but I get more than one max date (my excel has 2020 and 2021 dates, so it's picking dates from October 2020 and October 2021 for example). Dates are order according to Spanish so you will see month and days shifted:

I would suggest updating your calculated field to:
{ FIXED [id_constructionbuilding],DATETRUNC('month', [date_registered]), DATETRUNC('year', [date_registered]):MAX([date_registered])}
This will keep the level of detail (LOD) to the id_constru..., month and year.

Related

Dynamically compare sum of last n entries to sum of n entries depending of selected timespan

I have booking information containing booking values. Every booking has a createdAt date. What I have been doing so far, is to extract the month of the createdAt date, sum up the bookingValue and then compare it to the sum of the previous month using lag function. I used string input to select the corresponding month e.g. 2022-04. My code will execute and show the sum of bookingValue of the month April 2022 and also compare it to March 2022 using lag function.
What I´d like to do is to dynamically select a date range using a datepicker. Like this I can select a date range e.g. from 10th of May 2022 to 20th of May and get the sum of bookingValue. Now the only problem I have, is that my lag function won´t work anymore. What can I do?

Tableau, Week to Date, Month To Date, Year to Date parameter

I have a data set spanning 2 years and is updated daily, created a dashboard to give a view of incidents by date group. I have created a parameter using date trunc for Day/Week/Month/Quarter/Year. This is in Tableau.
I am trying to get the parameter to show a Week to date, Month to date and so on view. IE if on Weds 15th Dec I selected the weekly view, it would only show data for every week in the data set for Sat-Weds (My weeks go Sat-Fri) or the monthly view every month between 1st-15th
Ideally I am wanting this as a simple parameter for a drop down menu, I can do the week to date stuff as a rolling sum restarting every week in a separate table, but for ease I just need a date group function that will allow to do this.
Any suggestions would be appreciated.
Cheers
Pete
The solution is 5 parts:
Date Part Parameter
Max date [Max Date]
Dynamic date part of the Max date [Dynamic Date Part Max]
Dynamic date part of the historical dates [Dynamic Date Part]
Filter those date parts <= the Max date [Dynamic Date - Lass than Max]
Date Part Parameter
Max Date
This is the calculation you'd use with your dataset to find the max date.
{ MAX([Order Date]) }
In order to create a good example, I'm going to set my Max date to a specific date the falls in the middle of a week, in the middle of a month and middle of the year. I'm going use June 13th, 2018 as my Max Date.
So, if you want to follow along you can use the below date as your max date. You can also use this data set if you'd like.
DATE(#2018-06-13#)
Dynamic date part of the Max date
DATEPART([Select Date Part], [Max Date])
Dynamic date part of the Historical dates
DATEPART([Select Date Part], [Order Date])
Filter on Historical dates parts <= the Max Date
[Dynamic Date Part] <= [Dynamic Date Part Max]
Now that we have all the pieces we need let's check to make sure they are working as we would expect.
Looks like we're seeing all the days of the month that are <= the 13th.
When we change it to Day of the Week we see only the days of the week <= the 4th day of the week which is Wednesday when the week starts on Saturday.
Now let's calculate the running sum of sales along our dynamic date part to better help you with your example.
Drag the measure you want to calculate the running sum onto the label, then create a quick table calculation. We'll next need to edit this table calculation as so.
You'll then see your calculation working as you would expect.
Hope this was helpful. Happy vizzing!

Tableau: Same Day Last Year Auto Filter

I am trying to compare yesterday's data to the same day the year before. For example, yesterday is 11 November 2018. I want to compare to 12 November 2017 (same day but the year before). I am wanting this to be applied automatically on the filter so all I need to do is open the file and verify the numbers are correct before sending off the report.
Any help would be appreciated.
Thanks
There are many Tableau functions that manipulate dates. A couple in particular are relevant to your problem:
Today() - returns the current date
DateAdd() - adds or subtracts an interval from a date. For instance, DateAdd('year', Today(), -1) gives the date one year prior to today. The first argument to DateAdd is the level of granularity or date part.
DateDiff() - determines the difference of the interval between two dates. DateDiff('day', [Start Date], [End Date]) returns the number of days separating the two date arguments.
The functions are well documented in the online help. Construct the formulas you need and filter accordingly.
Isolate yesterday's date as its own field. For instance if that is the max date in your data, then {max([Date])} would create an LOD of the maximum date.
Then make a calculation that will display the same date last year:
year([Date]) = year([max_date])-1
and datepart('week',[Date]) = datepart('week',[max_date])
and datepart('weekday',[Date]) = datepart('weekday',[max_date])

Altering x-axis for dates in Tableau

I have a data set that has dates for many years. I can easily filter the data by month or week, but I was hoping to change the X axis to make it start in October and end in April.
Is there a way to do this in Tableau without altering the original data and listed dates?
I don't know about it ending in April since that would not be a full 12 months but you can make it start in October. Right click on your date field > Default Properties > Fiscal Year Start. Then select October.

Grails Model Count Number of occurence group by Date month, hour

I have a Grails Domain that contain two date feild
Date updated
Date created
I want to count number of rows based on updated time with respect to month or hour or year. How can I do that. The methods showed on Internet does not work. I am using grails version 2.4.4.
Update:
Example
I have a domain that contain four feids
Date Created
Date updated
Long id
Long idx
I want to find how many idx is there in every group when i group by hour. Like there can be 5 in 12h and 6 in 13th hour... so on.. How can i find those.... My comaparison is not fixed. It can be changed to mont or year... In year it will show the number of idx in each year. in month it will show the number of idx in each month..
How can I do this with grails...
You can use where detached query:
DomainClass.where { year( updated ) == 2014 }.count()
Similarly, hour(), minute() etc.
Refer WHERE queries for details.