Im trying to design a dashboard wherein I need a parameter to control 2 things.
If I select "Rolling 12", I should be able to see the last 12 months of my data with respect to current month. When I select "Rolling 12-2", I should be able to see
last 12 months of my data but excluding the latest 2 months. E.g If I'm in January 2018 then I should be able to see data excluding Jan 18 and Dec 17 (from Jan 17 to Nov 17). I have tried some techniques but without success. Can anyone help. Thanks.
Reference Tableau Workbook attached at link :
Using the Superstore sample data (I don't have 10.5 installed), I created the following boolean expression which you'd put in the filter shelf for True.
Give a parameter called rolling, create calc field as follows:
if [rolling] = 'Rolling 12'
then DATEDIFF('month',[Order Date],{max([Order Date])}) < 12
ELSEIF [rolling] = 'Rolling 12-2'
then DATEDIFF('month',[Order Date],{max([Order Date])}) < 12
and DATEDIFF('month',[Order Date],{max([Order Date])}) >= 2
end
Adjust the date name for your date field.
Related
Hi I am trying to get rolling 12 months calculation in Tableau which is working fine but it's not applying at the starting date.
Eg i want rolling 12 months from jan 2012 to till date. But even jan 2012 should display rolling 12 previous months.(eg it should show total value of last 12 months from jan 2012 to feb 2011.
How can i do that in tableau?
Use a late filter for the date. LOOKUP(ATTR([Date]),0)
Use that to remove the dates before 2012 but keeping the running sum from before then.
A late filter happens after the numbers have calculated, hence starting your running sum while accounting for what happened in the past.
This link has an example specifically referencing the running sum starting point.
I do have data set with multiple date columns with different values of dates across all the months and years. I want to create a report wherein when I select a Year, I want to list the count of dates across each months on that year. Based on one Year field selection, how can I apply filter across different date fields to display the counts for that particular year
Lets say we have the data set like this
Date 1 Date 2
1/3/2017 NA
1/23/2017 1/23/2017
1/14/2017 1/16/2017
2/2/2017 2/3/2017
NA 2/21/2017
3/1/2017 NA
3/3/2017 3/21/2017
.
.
.
12/1/2017 12/12/2017
My result should look like this when I pick the year 2017
Date 1 Date 2
Jan 3 2
Feb 1 2
Mar 2 1
.
.
Dec 1 1
I was able to apply filter on one column but when I try to apply on other columns, I am not getting desired result
Assuming you want to interact with your dashboard using a parameter, you can create one string parameter in order to input the year you want to analyze.
After that you just need to create 2 calculated fields to count if that year is "contained" in your dates:
if contains(str([Date 1]),[Parameter]) then 1 else 0 end
Keep in mind that there's no gaurantee you'll get all the available months in the calendar unless you have data for all of them.
In order to consider even blank dates, I created a Date Global calculated field as follow:
ifnull([Date 1],[Date 2])
Once you've created this fields/parameter (show parameter control), you can simply add them in your worksheet ad I did in the image:
I have a tableau worksheet that shows a count of records by date. Current system date is Mar 14 but my dataset has data only till Mar 9. Is it possible to show dates from Mar 10 - Mar 14 even though there is no data for this time frame.
Given is a snapshot of my worksheet, kindly let me know how could I include all dates in the row even though there is no data for this time period.
Select discrete row it will show the date on a sheet
We have YTD data only. I've been trying to get a MTD running across the table.
So I thought I can run a Table calculation type - "Difference From" previous month.
This works well except for the first month of the year.
Jan MTD = Jan YTD NOT Jan YTD less Dec YTD
So January numbers are never right.
Is there a way to say, If month = "Jan" don't perform the table calc?
regards
Gem
You probably have something like
ZN(SUM([YTD])) - LOOKUP(ZN(SUM([YTD])),-1)
Then, for the first entry, LOOKUP() will return null. All you need to do is to return 0 instead, using ZN()
ZN(SUM([YTD])) - ZN(LOOKUP(ZN(SUM([YTD])),-1))
In case you don't know, you need to go to Edit Table Calculation..., then Edit Formula...
EDIT: I understand you have a bigger problem, that is your rolling sum restarts every year. In that case you really need an IF statement, but it is possible to overcome your "it's not always the same starting month" problem. You just need to check if that month is the first in your list or multiple of 12:
IIF(-FIRST()%12 = 0,
ZN(SUM([YTD])),
ZN(SUM([YTD])) - LOOKUP(ZN(SUM([YTD])), -1))
You just have to understand the FIRST() function. It will return the distance from the current position to the starting position. So, if you start in February, in August First() will return -6.
And the modulo operator will guarantee you restart every 12 months
Thanks Inox.
You are correct.
However I was intending more like this:
IIF(min(month([period_date]))=1,
ZN(SUM([YTD])),
ZN(SUM([YTD])) - LOOKUP(ZN(SUM([YTD])), -1))
Since the formula is an aggregate, I had to use "min" for the date. That was my problem using the IIF function, which was not apparent in my question.
This will produce MTD beyond 1 year, When it reaches the second January, it will not subtract Dec YTD.
Only problem I have now though is, if you begin the table on a month other than January... ie Feb.
Feb MTD is not Feb YTD??
(this is another problem, my report is to produce a rolling 12 month)... ie Feb to Jan, Mar to Feb)
So far, I'm just displaying 2 years to get over this, so forcing it to start on January. Not really a solution, but it gets the information across 12 months.
Currently I am trying to come up with a leave tracking system using OpenOffice Calc, so I have two sheets of data:
sheet 1:
s/n name date start date end
1 test 3 Jan 2012 3 Jan 2012 <- formatted to date format
2 test 6 Jan 2012 8 Jan 2012
while sheet 2 should look like this after I add in the formula:
name 3Jan 4Jan 5Jan 6Jan 7Jan 8Jan <- formatted to date format
test 1 1 1 1
My problem is how to use a formula on the second sheet under the dates which would refer to sheet 1 and automatically add a 1 if the person is on leave on that day. The dates will give me a serial number if I were to get the value from the cell which I use to match the dates on sheet 1 and sheet 2.
Using VLOOKUP I was able to get the value of the date start and end in sheet 1 from sheet 2:
=VLOOKUP(A2;$A$2:$D$3;3;0)
=VLOOKUP(A2;$A$2:$D$3;4;0)
and then an IF statement to add a 1 or a "":
=IF(VLOOKUP(A2;$A$2:$D$3;3;0)=MID(B1;1;6);"1";"")
However I face a problem with this part with a leave of many days (example entry 2 in sheet 1 where the leave ranges from 6 - 8 Jan).
So I tried to compare the values if the date is greater than or equal to the start date and the date is less than or equal to the end date, but failed. This is the formula I tried:
=IF(VLOOKUP(A2;$A$2:$D$3;3;0)>=MID(B1;1;6)<=VLOOKUP(A2;$A$2:$D$3;4;0);"1";"")
Can anyone can help me with this issue or have any better ideas?
Assuming s/n is in A1 of your !st sheet and Name in A1 of your second sheet, in B2 of your second sheet and copied across to suit:
=IF(COUNTIFS(first.$B1:$B99;$A2;first.$C1:$C99;"<="&B$1;first.$D1:$D99;">="&B$1)=0;"";COUNTIFS(first.$B1:$B99;$A2;first.$C1:$C99;"<="&B$1;first.$D1:$D99;">="&B$1))