Extracting most recent record in REPORT SELECTION FORMULAS GROUP. Crystal 13 - date

I am extracting information on medication requests. For each medication request, say in the last 90 minutes, I also want to display a date for any previous time a drug was dispensed for the same patient. In many cases there will be no such history as its the first time the patient has had this drug.
I cannot seem to both show the most recent dates for those patient/drug combinations where there is a prior date but keep the records where there is no history of a prior drug being dispensed.
I have utilised Report, Selection Formulas Group as has worked in the past with different queries.
{#DispenseDT}=MAXIMUM({#DispenseDT},{#RefDRUGPATID})
NB DispenseDT is a formula joining Dispensed Date and Dispensed Time
NB RefDRUGPATID creates a unique reference for each Drug and Patient combination.
This appears to work in pulling through the most recent dispensed date/time for each DRUG/PATIENT combination. If I don't do this I get the first (oldest) record.
However, when I apply this I also lose records. I think this is because not all the DRUG/PATIENT combinations being requested have had previous records so when the formula cant find a MAXIMUM it excludes the record entirely.
I have tried doing something like if isnull({#DispenseDT}then " " else
ToText({#DispenseDT}=MAXIMUM({#DispenseDT},{#RefDRUGPATID})) but when I try and create a formula and display this I just seem to get either BLANKS or TRUE or FALSE displayed, not the "MAXIMUM" DispenseDT. It doesn't like me putting the formula within SELECTION FORMULAS GROUP either.
So in summary I am looking to pull the most recent historical dispensing date for a patient/drug combination for each new request made. But where there is no history of a drug being dispensed I still need to see the new dispensing request record.
I am using crystal reports 13.

Related

Query/filter by 3 AND criteria + countif

I'm trying to create a dynamic dashboard for tracking student attendance patterns. When you choose the student from the drop-down in cell C4 in the Student Tracker, the data and charts all change dynamically. The way I've created dynamic charts is by "hiding" queries and other calculations behind the charts and making the text the same color as the background so that they aren't visible. Here's a shared copy of the dashboard with anonymized data: https://docs.google.com/spreadsheets/d/1nyI6h8aiPcJiqPIDWE6AsmCIPt_Vhj0dHdKtmsoqfuk/edit
I'm trying to create a chart that will show monthly patterns for the selected student, looking at the percentage of times they were marked "Present", "Excused absence (E)", etc each month (very similar to the days of the week chart).
This is the formula I tried:
=Countif(Query(ATTDATABASE!$A$2:$M,"select E,G,I,K,M where C='"&$C$4&"' and B >= date '"&TEXT(8/1/2019,"yyyy-MM-dd")&"' and B <= date '"&TEXT(8/31/2019,"yyyy-MM-dd")&"'"),"Present")
It keeps counting 0, even though I know the selected student was marked present in August. Even if I take out the other columns and just leave it as "select E...", it still counts as zero, even though I know the student was marked present on a Monday (column E) in August. I know there's got to be a way to do this, but my Google Sheets chops just aren't quite strong enough yet to figure out the magic combo/syntax.
try:
=COUNTIF(IFERROR(QUERY(ATTDATABASE!$A$2:$M,
"select E,G,I,K,M
where C='"&$C$4&"'
and year(D) = 2019
and month(D)+1 ="&MONTH(LEFT($G20, 3)&1))), "Present")

Get full date range of linked field in tableau

Gif of problem
I am currently working on a dashboard in tableau, which shows the count of New-User-Signups and Interactions side-by-side given different date windows. The first New-User-Signup happened before the first Interaction, and the last Interaction happened after the last User Signup.
In order to choose a date window, I linked the date fields in both data sources, and made a date filter, which I applied to all worksheets using related data sources.
However, depending on which "date" field I choose, (from the User Signup table or the Interaction table), the "All Dates" option of the date filter only goes from start to end of that data source's date range.
No matter what I try, I exclude some entries in either one graph or the other. How can I make the "All Dates" filter go from the minimum first date between both data sources, to the maximum last date between the two data sources?
I run into this issue a lot with the data that I use. The problem is that the filter will only be able to contain dates that are in the dataset it is created off of, even if you link the data sources. When I run into this issue, I use parameters instead.
You can find instructions here:
https://kb.tableau.com/articles/howto/creating-a-filter-for-start-and-end-dates-parameters

Crystal reports - Can't filter on custom formula number field

Crystal reports don't let me use a custom count formula field to filter which transactions to show in a manager report.
I'm creating a Crystal report that team leaders are supposed to take out to see on how many occasions their employees have reported in sick. A record is only supposed to show if that person has reported in sick 6 or more times the last 12 months.
The report shows a record (a page) for each employee belonging to the managers organisational unit. Below the employee information is a subreport where I show the transactions from the salary/time system. Using select expert, I have filtered out the transactions that is supposed to show. I have then created a database field that count which day was 12 months back from today, and filtered so that only the transactions falling into this period shows.
My last problem is that I only want to show the record that has a minimum of 6 such transactions during the period. I created a formula field named #Antal ("amount" in Swedish) that simply counts the distinct number of dates in the "from"-date for the salary transactions I'm showing (since a change of law 2019-01-01 we needed to create a new transaction type, so some of the occasions after 2019 may have two transactions referring to one sick leave, thus I'm counting the first day of the period instead), DistinctCount ({P_LSTAT.P_SXXX06})
Now, the subreport has a new column with Antal (amount) that counts the amount of the desired salary transaction. I then try to use the selection formula to only show records where {#Antal} >= 6 but I get the following error:
This formula cannot be used because it must be evaluated later
Is there any other (better) way of doing this, or am I simply missing something?
For your selection based on {#Antal} >= 6 you need to use the group selection formula, not the record selection formula. Record selection is used to select records which meet the criteria before reading in the data. Group selection is used to filter out entire groups of records based on summarised values, after the records have been read in and the summaries calculated - which sounds like exactly what you need here.
The value of a Formula Field is out of scope when the Select Expert is evaluated.
There is no process for calculating the value of a Formula Field before it is printed within the section of the report it is placed. The Select Expert is evaluated prior to any section of the report being printed, so at this time all Formula Fields are effectively Nothing.

Volume of an Incident Queue at a Point in Time

I have an incident queue, consisting of a record number-string, the open time - datetime, and a close time-datetime. The records go back a year or so. What I am trying to get is a line graph displaying the queue volume as it was at 8PM each day. So if a ticket was opened before 8PM on that day or anytime on a previous day, but not closed as of 8, it should be contained in the population.
I tried the below, but this won't work because it doesn't really take into account multiple days.
If DATEPART('hour',[CloseTimeActual])>18 AND DATEPART('minute',[CloseTimeActual])>=0 AND DATEPART('hour',[OpenTimeActual])<=18 THEN 1
ELSE 0
END
Has anyone dealt with this problem before? I am using Tableau 8.2, cannot use 9 yet due to company license so please only propose 8.2 solutions. Thanks in advance.
For tracking history of state changes, the easiest approach is to reshape your data so each row represents a change in an incident state. So there would be a row representing the creation of each incident, and a row representing each other state change, say assignment, resolution, cancellation etc. You probably want columns to represent an incident number, date of the state change and type of state change.
Then you can write a calculated field that returns +1, -1 or 0 to to express how the state change effects the number of currently open incidents. Then you use a running total to see the total number open at a given time.
You may need to show missing date values or add padding if state changes are rare. For other analytical questions, structuring your data with one record per incident may be more convenient. To avoid duplication, you might want to use database views or custom SQL with UNION ALL clauses to allow both views of the same underlying database tables.
It's always a good idea to be able to fill in the blank for "Each record in my dataset represents exactly one _________"
Tableau 9 has some reshaping capability in the data connection pane, or you can preprocess the data or create a view in the database to reshape it. Alternatively, you can specify a Union in Tableau with some calculated fields (or similarly custom SQL with a UNION ALL clause). Here is a brief illustration:
select open_date as Date,
"OPEN" as Action,
1 as Queue_Change,
<other columns if desired>
from incidents
UNION ALL
select close_date as Date,
"CLOSE" as Action,
-1 as Queue_Change,
<other columns if desired>
from incidents
where close_date is not null
Now you can use a running sum for SUM(Queue_Change) to see the number of open incidents over time. If you have other columns like priority, department, type etc, you can filter and group as usual in Tableau. This data source can be in addition to your previous one. You don't have ta have a single view of the data for every worksheet in your workbook. Sometimes you want a few different connections to the same data at different levels of detail or for perspectives.

Crystal Report Gauge On Change of Date Period

I have a Crystal Report where I am using the 'gauge' chart to display On Time delivery for a business. The Gauge requires an "On Change Of", but I ahve two seperate values I want to display on the same gauge, one for overall and one for the last week. I can do this, by creating a null formula and setting the OnChange of to that, but then the needles are the same color. Any thoughts on how I can get one needle for overall and one needle for last week?
My Table is just a list of Manufacutring Orders with Due Dates and Completion Dates. I use a formula to decide if the order was on time, if it was I print the Order Number. Then I use a summary field with a distinct count of order numbers to determinie the total number on time orders. This divide by the total distinct order counts and then I get a percentage for OTD...
Okay this one deserves some more explanation. For each detail, which was essentially a list of sales orders, I had a date requested and a date completed. From those two fields I calculated a third field that returned either "On Time", "Late", or "3 Day Window" and I wanted to display a gauge chart of all records On Time.... Our OTD %
In addition to this I wanted to display the weekly numbers versus the numbers prior to that week. To do this I created a fourth column that returned either "This Week" or "Historical". I could now do a Multiple gauge type chart for each record with an on change of OTD State and Weeklyorhistorical. This produces side by side gauges labeled correctly with historical and weekly OTD.