How to display month and YTD data on same group band in Crystal Reports - crystal-reports

I am working on a productivity report. I need it to display units for the month along with YTD units.
Example:
Month units YTD Units
Staff (group 1)
Accounting Period (group 2)
Service Category (group 2)
Detail - services with minutes that are calculated into minutes. This may or may not be hidden.
Service Category (footer) Units sum for period Total Units sum
Page Break
Accounting period.... and so on until we run out of accounting periods for that staff with services, then onto the next staff.
Units are being calculated in a formula field based off of minutes of the service. How can I accurately display the year to date units? Everything I've tried hasn't worked. Perhaps I'm doing a running total wrong but it told me I couldn't use a formula field in it (units). I hope my explanation makes sense.

Related

Trying to Average number of accounts by hour, day of week, and month

I'm in healthcare and we're trying to assess the number of discharges we have per hour of day, but we'd also like to be able to filter them down by day of week, or specific month, or even a particular day of week in a particular month (e.g. " what is the average number of discharges per hour on Mondays in January?")
I'm confident that Tableau can do this, but haven't been able to make the averages show up in my line graph... every time that I convert it from COUNT to AVG, the line simply goes straight. I got close when I did a table calculation to find the Average (dividing the count per hour by the number of days captured in the report), but when I add a filter for either the month or day of week, selecting one of the options of the filter reduces the total number that is being counted, rather than re-averaging the non-filtered items. (i.e. if the average of the 7 days of the week is "10" for a particular hour, and I deselect the first three days of the week, it's now saying that my average for that hour is roughly 6, despite the fact that all of the days are very close to 10 at that hour.)
Currently, my data table has the following columns:
Account#/MonthYear/HourOfDay/DayOfWeek
ex.12345678/ Jan-17 / 12 /Sunday
I would just create a few calculated fields to differentiate the parts of the calendar you might want to filter/aggregate on. Mixing the month and day of the week with filtering is pretty straight forward with the calculated fields. Then do standard summing to get what you are looking for because an average count of records is always one unless you are throwing some other calculation into the mix. I threw a quick example up on Tableau Public for you to get the idea.

Tableau: Calculate Monthly and Yearly Averages from Days

I have a few years of data by day that looks like this:
Date Count
1/1/2015 1000
1/2/2015 1010
1/3/2015 1040
I would like to create a calculation that allows me to switch between Day, Month and Year using Tableau's date formats without having to calculate the average for each individual format. For instance, the monthly average for Jan 2015 would be the total of Count for all 31 days in January 2015 divided by 31.
Since you have no missing data (days) and no duplicate data, the solution is extremely easy.
Place the Count field on any shelf (except the filter shelf). For example, place it on the Rows shelf. Click on the Count field on the Rows shelf and change the aggregation to AVG(). You should see the AVG(Count) of all your data rows at this point.
Place the Date field on any shelf (except the filter shelf). For example, place it on the Columns shelf. Click on the Date field pill on the Columns shelf, and choose the level of granularity you wish from the SECOND batch of choices. (The first batch returns date parts, not dates) For example, choose Month. You'll see the Avg(Count) per month.
Place any other dimensions on shelves to either filter to specific dimension values or to show the average counts broken down by your other dimensions.
Users can drill up or down the granularity of your dates by clicking the + or - icons by the date axis, or by clicking on the Date pill. You can choose to display the dates as a continuous or discrete value.
If you don't like the +/- UI, then you can create a string valued parameter with values: year, quarter, month, day etc, and then create a calculated field using the date_trunc() function to allow, say, a dashboard user to to choose the date granularity from a different type of UI control.

Aggregating data from the US stock market in Tableau, using different time frames

I am a very basic user of tableau and I have not found an answer to my question.
I have a txt file that has historical daily data for 98% of all the stocks in the US, with their daily capitalization. Each stocks has its TICKER, Daily Market Value for every trading day of the year, and its SECTOR.
I did a simple time series that display SUM([Mktval]) (sum of all individual market values) across all stocks, on a daily daily, and where I can see that the total value as of 2016 is about 24 Trillion USD, as in the image below.
When I change the view column from DAY to YEAR, I don't see the right values, but something a lot larger. So I realized that I need to do SUM([Mktval])/252 to get the right value for a year (there are 252 trading days in a year).
If I change the view to MONTH, as in the chart below, the numbers are again wrong because 252 is not the right value to use in the division.
Is there any way that Tableau can adjust the values automatically to reflect the AVG MktVal across different time intervals?
Thanks
Replace SUM(Mktval) on the Rows shelf with the following calculated field
avg({ fixed day(Date1) : sum(Mktval) })
That solution is all in one step. It is perhaps a bit more clear to use 2 steps. First, create a calculated field called total_daily_market_value defined as
{ fixed day(Date1) : sum(Mktval) }
Then make sure that calculated field is a measure. It is an LOD calculation that you can think of as a separate table with one value for each day showing the total market value for that day.
Drag that measure to a shelf, and then change the aggregation function to AVG(), MEDIAN(), MIN(), MAX() or STDEV() as desired. Tableau will aggregate the total_daily_market_value using your chosen aggregation function for whatever values of Date1 are in your view.

Calculate rate in Crystal Report

I need to calculate the rate of infection per patient from a report. This report returns the number of months the patient had a catheter and the number of infections they had during this time.
What i need to do is add a column at the end that displays the infection rate per patient. For example, if a patient has had a catheter in for 12 month and they have had 2 infections, the rate is 2:12 or 1:6.
How do i create this in Crystal Reports? Not used it much so learning.
Cheers,
Mike D
Edit: The data is from a MySQL database that holds all patient information. I extracted the date that the catheter was inserted as well as the date it was removed and the nunber of infections the patient had during this time. I then used MySQL to calculate the number of months it was in from those two fields.
No I need to calculate (with MySQL or Crystal) the rate of infection per month.
For example, a patient has a catheter for 12 months and has 2 infections, the rate is 2:12 or 1:6.
I hope this is clearer.
It will be a bit complex report.
First group by patient that will be group 1
Group 2 will be date
Detail part will be list of infections for that patient as recorded in database
You can take the count of dates that is group2 count and count of infections and display in group 1 as required...you can manipulate in the format you need.
If you dont need then you can just display group 1 and supress group2 and details.
Let me know after trying this.
Concordinate your data from the database and try formula in cyrstal reports or try doing all the back end calculative steps in SQl and just use the reports to show those data sets. its far more easy to do those things in SQL than Crystal Reports.
-Sid

Crystal Reports 9 Graphs/Chart

I have a cross tab with data showing clients per hour per day. So the rows are days of the week and the columns are the hours of the day, with the values being the number of clients.
Now to the main point :), I want to produce a graph for each day of the week, that shows the number of clients per hour for that day. So the report would have 8 graphs in total, one for each day and then an "all days" graph. See Picture:
Click, as I can't include pictures yet
Any idea how to do this, as I can't find a filter or anything, and the only graph I can get is all on one, with multiple bar lines for the days, in each hour block.
Ok, just figured this out :)
I have created a formula for each week day, that contains the following:
if {Command.day} = "Monday"
then {Command.kpi1}
else 0
Then in the chart expert, use this formula field for the values...so simple but overlooked :#