Crystal Report Show Multiple Records Following Parameter Fields - crystal-reports

I am trying to create a report for a spa technicians schedule for their day. It consists of a scheduled time, and their break times.
I am making a crystal report and have the following set up in Preview:
There is actually two breaks in my database, another one for 4:30 - 5:45. How do I get this second one to show as well?
I have this set up in Design:
#Breaks has the formula ToText(cTime({cmprovblk.from_time}),'h:mmtt') + '-' + ToText(cTime({cmprovblk.to_time}),'h:mmtt').
The desired result, crudely drawn, is:
Here is the table that provides the schedule, filtered by provider_code and sba_date:
provider_code | property_code | sba_date | from_time | to_time
--------------|---------------|------------|-----------|--------
100 | | 2017-04-12 | 09:00 | 17:45
Here is the table that provides the breaks, filtered by provider_code and sba_date:
provider_code | sba_date | from_time | to_time | block_reason_code
--------------|------------|-----------|---------|------------------
100 | 2017-04-12 | 12:45 | 13:30 | lunch
100 | 2017-04-12 | 16:30 | 17:45 | gonehome
Moving the breaks to the Details a section just makes it keep repeating for some reason.. Here's what it looks like:
and this goes on for half the second page.
Here are my links:

You can put another #Breaks formula field just below the existing one and then suppress that with the condition like if {Table1.from_time}="16:30" and {Table1.to_time}="17:45" then false Else true. Similarly do the same for the previous #Breaks formula field too.

Related

Is it possible to make multiple fields default to the same date, but also be individually editable?

I am VERY new to Access - I was sort of thrust into designing a database for a research project I'm involved in. So, please bear with me because I know next to nothing :) The problem I am having is thus:
My database is for a medical research project, and is very time and date dependent, by which I mean I need to capture the date and time for each piece of data so that we end up with a sort of timeline of events for each subject.
As is, I have something like the following for each piece of data: (Each in it's own field)
ArrivalDate
ArrivalTime
HeartRateDate
HeartRateTime
HeartRateData
TemperatureDate
TemperatureTime
TemperatureData
BloodPressureDate
BloodPressureTime
BloodPressureData
There are around 200 similar pieces of data that I need to collect for each patient. To avoid having to re-enter the same data over and over, and also to reduce the potential for error, I would like to have all of the date fields in a given patient record default to the first one that is entered, in this case "Arrival Date". However, I also need each date field to be editable without affecting the others. The reason for this is that in the event that a patient's visit occurs over the span of a few days we can accurately record that.
I have tried messing around with the default value setting, as well as setting the control source to reference the "Arrival Date" field, but then of course any changes to one field affect them all. I am not even sure that what I am trying to do is possible but I will appreciate any help and/or suggestions!
Thank you in advance
Having all this data in separate columns of a big table isn't going to work. You don't measure things like temperature or blood pressure only once per patient, do you?
This is a classic one-to-many relation.
You should have a separate Measurements table, looking e.g. like this:
+--------+-----------+---------------+------------------+-----------+
| MeasID | PatientID | MeasType | MeasDateTime | MeasValue |
+--------+-----------+---------------+------------------+-----------+
| 1 | 1 | Temperature | 2017-05-17 14:30 | 38.2 |
| 2 | 1 | BloodPressure | 2017-05-17 14:30 | 130/90 |
| 3 | 1 | Temperature | 2017-05-17 18:00 | 38.5 |
| 4 | 2 | Temperature | etc. | |
+--------+-----------+---------------+------------------+-----------+
As Barmar wrote, there is no reason to have separate columns for date and time.
In the form where measurements are entered, you can use the BeforeInsert event to set MeasDateTime to the current time, with the Now() function.
So the user never has to enter it manually, but they can edit it if the measurement was at a different time than entering the data.

Calculate the percentage of a column which has redundant rows in Tableau

I want to calculate the percentage of a column which has redundant rows.
For example ... I would like to calculate the percentage of "Success" for A and B in the below table
+-------+---------+
| Name | Result |
+-------+---------+
| A | Success |
| B | Success |
| A | Fail |
| A | Success |
| B | Fail |
| B | Fail |
| A | Success |
+-------+---------+
I tried using Calculated field by putting If([NAME]) = "Success" then 1 else 0
and then editing the table calculation to Percentage -> table across and down... but didn't work :(
You can absolutely use the "Percent of Total" table calculation for this. The tricky bit is going into the "Edit Table Calculation" dialog and telling Tableau how you want it to perform the calculation.
Here's an example of how to do this that you can adjust to fit your specific needs. Place [Name] and [Result] in the Rows shelf. Then place SUM(Number of Records) into Text. You'll end up with something like this:
Name Result | |
---------------------+-----+
A Fail | 1 |
Success | 3 |
--------------------+-----+
B Fail | 2 |
Success | 1 |
--------------------+-----+
Then right click on SUM(Number of Records) and click "Add Table Calculation...". At the top of the Table Calculation dialog, go to "Calculation Type:" and choose "Percent of Total". In "Summarize the values from:", it will default to "Table (Down)". Go ahead and hit Apply at this point and see what happens. Bad news - it's wrong.
Name Result | |
---------------------+-----+
A Fail | 14% |
Success | 43% |
--------------------+-----+
B Fail | 29% |
Success | 14% |
--------------------+-----+
The default "Table (Down)" is almost never what you actually want. That says to calculate the percent of total for your entire partition, but you'd actually like to see that percent of total for each Name.
Until you get really good at this part (and maybe even after you've become a Tableau Zen Master and a Tableau god among men), I recommend always going to the advanced menu when you're defining your table calculations. It's a good opportunity to really think through exactly how you want Tableau to perform the calculation. In this case, you want to calculate the percent of each result (Success and Fail) for each name.
Go to the Advanced dialog (under "Summarize the values from:"). You'll see Name and Result under Partitioning and nothing under Addressing. Move Result over to Addressing and leave Name under Partitioning. What you're saying here is "I want Tableau to calculate the percent of each result (Success or Failure). I want it to do this for each name."
Apply those changes, and you should see something like this:
Name Result | |
---------------------+-----+
A Fail | 25% |
Success | 75% |
--------------------+-----+
B Fail | 67% |
Success | 33% |
--------------------+-----+
Perfect. If you just want to see the Successes, just right click on "Fail" in the table and click Hide. Do NOT filter them out. That will remove those rows from your partition, and thus from the total that is considered in the percent of total calculation. By hiding the Fails instead of filtering them, you keep them in the partition but don't show them in the data view.

Calculate median and average in a partition in Tableau using table calculation

I have a details table of posts and subjects digged from a forum. Row is the single subject (ie postID and subjectIS is the primary key for the table), then I have some measures at subject level and some at post level. For example:
+---------+-------------+--------------+------------+--------------+--------+
| post.ID | post.Author | post.Replies | subject.ID | subject.Rank | year |
+---------+-------------+--------------+------------+--------------+--------+
| 1 | mike | 10 | movie | 4 | 1990 |
| 1 | mike | 10 | comics | 6 | 1990 |
| 2 | sarah | 0 | tv | 10 | 2001 |
| 3 | tom | 4 | tv | 10 | 2003 |
| 3 | tom | 4 | comics | 6 | 2003 |
| 4 | mike | 1 | movie | 4 | 2008 |
+---------+-------------+--------------+------------+--------------+--------+
I want to study the trend of posts and subjects by year and color it by subject.Rank.
Firsts are easily measured putting COUNTD(post.ID) and COUNTD(subject.ID) in rows and 'year' in column.
But if I drag MEDIAN(subject.Rank) in Color, I got a wrong result: it's not calculated at distinct subject.ID level but at row level.
I think I can accomplish it using table calculation features, but I have no idea on how to proceed.
It sounds like you are trying to treat Subject.Rank as a dimension, instead of as a measure. If so, just convert it to a dimension on the worksheet in question by right clicking on the field and choosing dimension. You can also convert it to a dimension in the data pane by dragging the field from the measures section up to the dimensions section. That will tell Tableau to treat that field as a dimension by default in the future.
A field can be treated a dimension in some cases, and a measure in others. Depends on what you are trying to achieve. If you are familiar with SQL, dimensions are used to partition data rows for aggregation using the GROUP BY clause.
Finally, count distinct (COUNTD) can be expensive on large datasets. Often, you can get the same result another way. So try to think of other approaches and save COUNTD for when you really need it.
Try using {fixed [1st LEVEL],[2nd level]: median()}
or
Table calculation approach
when you put in median there is an edit table calculation under advance compute using put you fields in there(Make sure its ordered the way you want it to calculate when you select them) then click OK select the at which level and restart every

JasperReports grouping changeable by user

I have no idea if this is possible or not but I'm trying figure out if it is possible to use iReport Designer to create reports where the user viewing the report is able to control the grouping.
For example I would like the user to be able to re-order the grouping and also change to which degree the report is grouped (only on one field or on multiple ones).
I don't mean SQL grouping btw, I mean for example grouping by Account and then Agent:
| Account | Agent | Invoice | Total |
+----------+---------+----------+-------+
| Account1 | | | |
| | Joe | | |
| | | Invoice2 | $600 |
| | | Invoice1 | $300 |
| Account2 | | | |
| | Sam | | |
| | | Invoice4 | $120 |
| | | Invoice7 | $230 |
| | Joe | | |
| | | Invoice3 | $200 |
+----------+-- ------+----------+-------+
And what I'm trying to figure out is, can you use iReport to make this grouping dynamic? That is, that the user might want to group by Agent first and Account second and rather than have one report for each grouping it'd be nice if there was a way of doing this with iReport.
Yes, it should be possible to create reports like that. But depending on your exact needs it may not be practical (as Alex K indicated).
If you take only your example of grouping on Account then Agent or grouping on Agent then account, it would be simple. Have a parameter that let's the user specify this choice. It would probably be a drop down list. Then in the report you would have fields like this:
Today's version: $F{Account} and $F{Agent}
Dynamic version: $P{AcctFirst} ? $F{Account} : $F{Agent} and $P{AcctFirst} ? $F{Agent} : $F{Account}
Likewise, the group definition would need to include the new AcctFirst param.
But it won't extend nicely. What if the 2 fields are different data types? What if you want to let the user choose from 3 or 4 or N fields? Each of those is solvable... but the report becomes exponentially more complex.
By the way, it's relatively common request. You'll see features like this make their way into JasperReports. But for now it's a tough one.

How should this user process be implemented to make it as intuitive as possible

I have to create this process:
you have an arbitrary list of people
you have to set their working schedule in terms of 5-2 or 6-4 (workdays and free days)
you have to schedule it for several months ahead (usually 3 or 12)
schedule sequence repeats
schedule sequence starts on any day for any person - so first work day is not necessarily on first Monday when you start setting schedule
So this is the process I have to implement. To make it more fast I want to set scheduling for multiple people on a single page (hence a list of users). Otherwise one would probably do this on some person's details page.
I wonder how should I implement this in a web application. I can use Ajax and advanced dynamic scenarios. I would like to make it as intuitive as possible and as simple as well so it shouldn't be to complicated for users doing it.
One possible solution
Each user is presented with this kind of a list row:
John Doe | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | ...
Jane Doe | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | ...
Joe Bloggs | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | ...
Harry Wotsit | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | ...
User clicks all days of the first sequence to make them orange/grey (working/free)
Drags over the sequence (like drag cells in Excel to select them) and then an icon would appear at the end (probably a sort of an arrow) that
user would then click to copy the same sequence to the end of schedule (similar to the small square on the right-bottom side of selected cells in Excel that makes it possible to copy those cells as long as you drag the square around.
I'm not sure whether this is the optimal and intuitive process.
Few hints:
use calendar control ( or equivalent in mvc) since it is more intuitive than row
try to avoid drag & drop because it's slow if you have to do it many times
try to minimalize click number needed to do a task. For examample when user select 5-2 term type and click in calendar to mark date when workdays starts this term should be assigned as default so user dont have to choose it again when want to mark another date as starting of 5-2 period.
use list with checkboxs to allow selecting many users
Does it have to be that snazzy??
You could simply have several text boxes, "daysOn", "daysOff", "startDate", "repeatX"
This would allow you to simply create patterns, which you could then display in some snazzy way.
Also, I would probably do this on a per user basis, so user at a time, if a company has several thousand workers on shift patterns you would not want to edit or display all that info in one shot. Would you??
Hope this helps.