Summing up all rows for each column - tableau-api

Please find attached workbook in the post.Post at Tableau community forum
This is what I am doing:
I have a list of tasks with a start date and assigned to one of the companies.
I want to find the time it takes between the tasks for every company. Then I need to categorize those hours in one of the 5 categories such as [if hours less than 5 then "On Demand"] and so on.
I want a view which can show name of the company and count of each of the categories. I am unable to attach the workbook here so if you want refer it then find the link above.
So, steps are:
1) find hours between consecutive dates for each company.
for ex: company 1 start date 1 : null
company 1 start date 2 : datediff('hour',start date, start date 2)
company 1 start date 3 : datediff('hour',start date 2, start date 3)
company 2: start date 1 : null
company 2 start date 2 : datediff('hour',start date, start date 2)
2) categorize hours into different categories.
eg: if hours less than 5 then "On Demand"
Now I want the view as:
company Category1 category2
CA 1
MA 20 30
Any help would be appreciated.

Related

SRSS 2016/Report Builder 2016 - row groups not able to collate by date?

I'm trying to make a report of daily work for a group of users in a database.
it's filtered by a date range, start date and end date. It then shows a list of the users and a total of things they did during that date range.
My boss wants it to then be expandable to show a breakdown of daily totals.
I can get it to open up and show a breakdown, but it's showing like this example here:
7-1-2018 to 7-2-2018
Jane Doe 5
7/1/2018 1
7/1/2018 1
7/1/2018 1
7/2/2018 1
7/2/2018 1
I've tried to mess with the groups of which there are currenlty only two, the name and the 'dateindexed' which is the entry in the database for when they do what they do. IT has a time stamp on it was well, but need to just have date and total.
I've tried to aggregate it and it then throws an error about no aggregation being allowed when there are filters present in the report.
Any tips or tricks to get this to collapse down on just the date and give a total for the days?
Thank you in advance.

Use one date filter on multiple columns in tableau

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:

How to set the SQL Query for a Report?

Crystal Reports 2011.
Database is MS Access 2003
I have the following tables:
Calendar
has Date entries for the current and next Year, for every Day of the Year, plus some Status Fields marking certain days as "Special" (Joining this table so I have a record for Days with no activity.
Staff table
StaffNo
Name
.
.
.
DayResults
Date
StaffNo
Status
.
.
.
The DayResults table has one entry per Day and Staff.
Entries are only made when the staff gets an entry by the Program for Status or other events. Staff that does not log in the system has no entry for this Day.
So, in case of John not showing up on July 2nd, i have no entry for him for this Day. But I need an entry for my report!
I need to create a Report that fetches Data from the DayResults Table and make calculations on the Parameters here, in order to calculate a Daily as ell as Period Bonus.
The rules for this Bonus require that a Day without activity (i.e. No Show) results in a negative bonus amount.
Therefore I need to have a select statement which creates an entry FOR EACH DAY FOR EACH STAFF.
This should look like this:
Date StaffNo Name Status
2016/07/01 1 Jim 1
2016/07/01 2 John 2
2016/07/02 1 Jim 2
2016/07/02 2 John NULL
(John did not show up on 2016/07/02 ...)
SELECT Calendar.Date, Staff.StaffNo, Staff.NickName, DayResults.Status
FROM Staff LEFT JOIN (Calendar RIGHT JOIN DayResults ON Calendar.Date = DayResults.Date) ON Staff.StaffNo = DayResults.StaffNo;
Unfortunately, no entry here for John on July 2nd?
Any idea how to proceed?
Manfred

TABLEAU Calculating a Running DISTINCT COUNT on usernames for last 3 months

Issue:
Need to show RUNNING DISTINCT users per 3-month interval^^. (See goal table as reference). However, “COUNTD” does not help even after table calculation or “WINDOW_COUNT” or “WINDOW_SUM” function.
^^RUNNING DISTINCT user means DISTINCT users in a period of time (Jan - Mar, Feb – Apr, etc.). The COUNTD option only COUNT DISTINCT users in a window. This process should go over 3-month window to find the DISTINCT users.
Original Table
Date Username
1/1/2016 A
1/1/2016 B
1/2/2016 C
2/1/2016 A
2/1/2016 B
2/2/2016 B
3/1/2016 B
3/1/2016 C
3/2/2016 D
4/1/2016 A
4/1/2016 C
4/2/2016 D
4/3/2016 F
5/1/2016 D
5/2/2016 F
6/1/2016 D
6/2/2016 F
6/3/2016 G
6/4/2016 H
Goal Table
Tried Methods:
Step-by-step:
Tried to distribute the problem into steps, but due to columnar nature of tableau, I cannot successfully run COUNT or SUM (any aggregate command) on the LAST STEP of the solution.
STEP 0 Raw Data
This tables show the structure Data, as it is in the original table.
STEP 1 COUNT usernames by MONTH
The table show the count of users by month. You will notice because user B had 2 entries he is counted twice. In the next step we use DISTINCT COUNT to fix this issue.
STEP 2 DISTINCT COUNT by MONTH
Now we can see who all were present in a month, next step would be to see running DISTINCT COUNT by MONTH for 3 months
STEP 3 RUNNING DISTINCT COUNT for 3 months
Now we can see the SUM of DISTINCT COUNT of usernames for running 3 months. If you turn the MONTH INTERVAL to 1 from 3, you can see STEP 2 table.
LAST STEP Issue Step
GOAL: Need the GRAND TOTAL to be the SUM of MONTH column.
Request:
I want to calculate the SUM of '1' by MONTH. However, I am using WINDOW function and aggregating the data that gave me an Error.
WHAT I NEED
Jan Feb March April May Jun
3 3 4 5 5 6
WHAT I GOT
Jan Feb March April May Jun
1 1 1 1 1 1
My Output after tried methods: Attached twbx file. DISTINCT_count_running_v1
HELP taken:
https://community.tableau.com/thread/119179 ; Tried this method but stuck at last step
https://community.tableau.com/thread/122852 ; Used some parts of this solution
The way I approached the problem was identifying the minimum login date for each user and then using that date to count the distinct number of users. For example, I have data in this format. I created a calculated field called Min User Login Date as { FIXED [User]:MIN([Date])} and then did a CNTD(USER) on Min User Login Date to get the unique user count by date. If you want running total, then you can do quick table calculation on Running Total on CNTD(USER) field.
You need to put Month(date) and count(username) in the columns then you will get result what you expect.
See screen below

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.