Visual Studio 2008 - name with more than one visit. I need an expression to count a distinct name ID on a date - date

I have a Visual Studio 2008 report with name, nameID, date of service, DOB and several other columns. I need to count the distinct name (using the name ID) visits (date of service). Some names have more than one date of service with more than 1 transaction (names=30, datesvc=36, transactions=80).
They are grouped by Name, NameID (hidden), DateSvc, Transaction.
I thought Count(DateSvc) would work but it gives me the same amount of transactions, not visits.
Any help is appreciated.
I cant put a sample of the data due to confidentiality. But here's a typed sample of it:
Name......Date......DOB......More columns
DOB to the right can be several rows depending on the transaction
Service Date can span one or several rows depending on the date of the transaction
The name spans all rows for that persons transactions on the specific service date
Name.....1/1/16.....9/5/2008.....trans 1 for that day
...............1/4/16.....9/5/2008.....trans 1 for that day (same person)
...............1/4/16.....9/5/2008.....trans 2 for that day (same person)
Name.....6/9/16.....3/7/2002.....trans 1 for that day
Name.....6/9/16.....5/1/2000.....trans 1 for that day
This should show 3 names, 4 visits and 5 transactions
The 4 visits is where I'm having the problem.
Or a Snippet of the above but with data deleted out:
I hope this gives more clarity.

Based on the example you put in your question I built a tablix with the following expressions:
Total Names: =CountDistinct(Fields!Name.Value)
Total Visits: =CountDistinct(Fields!Name.Value & "-" & Fields!Date.Value)
Total Transactions: =Count(Fields!Record.Value)
In your case Record should be MedicalRecordNum and Name should be PatientID instead of the name to avoid counting people with the same name.
The result is:
Let me know if this helps.

Related

How to MATCH Dates in separate Columns and then SUM all values for a specific Date? (Google Sheets)

I am trying to create a stock portfolio tracker.
Table 1 has all transactions in this format: Date | Irrelevant | Amount Bought (+) or Sold (-).
Table 2 has all Dates for every Day from the Date of the first purchase until the current Date.
Table 1 Table 2
I am trying to get a Formula that calculates the total amount of shares bought/sold on a given day. Table 2 should then look like this:
Goal (A) Goal (B) Goal (C)
I have tried some array formulas but cant figure out how SUM all Amounts for a specific Date.
This is what I currently have:
=ArrayFormula(INDEX(Transactions!$B$12:D, MATCH (TRUE,EXACT(Transactions!$B$12:B, B7),0)))
I am thankful for any help!
I believe this isn't really a proper question for stackoverflow, but try `=SUMIF(Transactions!$B$12:$B, B25, Transactions!$D$12:$D)' and just drag it down (or Ctrl+D).

Tableau measure count items if between dates

What I am trying to achieve is to get a count of people employed in a particular period.
I have 3 variables:
Employee ID (integer)
Hire date (date)
Termination date (date or null)
Example
the formula I am looking for is something like
if termination_date is null
then
count employee_ID in
dates between Hire_date and max of either hire_date or termination_date
else
count employee ID in
dates between hire_date and termination_date
This aims to show the dynamic of staff level over the time.
I am new to Tableau, not sure how to even start with it. Any suggestions welcome.
This problem will be simpler if you reshape your data to have the following three columns
Employee ID
Date
Action. (where action takes on the values of ‘Hire’ or ‘Terminate’).
Each data row represents one change in status for an employees. If an employee had a termination date, they will have two records in this new format, otherwise just one record showing the hiring date.
You can reshape your data by hand, or leave the original and use Tableau Prep or the Tableau data source page to reshape using a self Union and a few simple calculated fields.
Define a calculated field called Staffing_Change as
if Action=‘Hire’ then 1 else -1 end
Now you can plot the change in staff level over time by putting exact date on columns and sum(Staffing_Change) on Rows. You can use a quick Table calc, Running Sum, to see the net staffing level. For line mark types, I’d use a step style by pressing on the path button on the Marks card. Otherwise, the chart can give the impression of fractional number of employees.

Segregate Products based on shipping <SQL>

I have 10 different products (A,B,C),..,J)have multiple purchase dates (by various customers) and delivery dates. I want to see which products have the date difference of less than 5 days. If the date difference is less than 5 days, which products have customer rating less more than 3.If the above criteria is satisfied I want to fetch those products that has the minimum date difference from the queue along with the "Important_date".If there are same minimum date difference for a particular product then I would like to select the top one among the same product in recent times and mark the purchase date as the "Important_date".
The columns in the table are: Product,Purchasedate,deliverydate,date_difference,customer_rating.
I am trying to use case statements to solve the problem in PostgreSQL.
I am looking for an output which will give me all the columns of the table along with "Important_date."

How To EXPRESSION with WHERE " count Orders WHERE customer = Mr. Smith "?

I am a beginner in iReport and I cant program Java so I hope you can give me an idea.
I've already managed to make a chart that displays how often all customers have ordered in february, march,... etc.
Thats how I did it:
In category expression I have: $F{Month}
In value expression I have : $F{count(Orders)}
But I want to display how often only one customer (for example customer a) has ordered in february, march,... etc.
I have the following values which i can use:
Month, Orders and Customers(here are all customer names saved)
-------//-----------UPDATE--------------//-----------------------------------
I want to display a chart which represents the total orders per month of a customer. But iam trying to display my 3 customers (my database has only 3) in only one chart (stacked).
For example(see picture above): I want to display the total orders from Customer A (yellow) in february. And I want to display the total orders from Customer B (blue) in february and the same for customer C.
The customers should be displayed stacked (3 in every month) and every customer should have a different color plus the total orders from every customer should be displayed ...like in picture above for example:
customer A(yellow) made 3 total orders in february, Customer B(blue) made 2 total orders in february, customer C..etc.
it is very important that every month displays 3 customers...stacked.
How do I do this?
I appreciate every idea.
From what I have understood from your question, you want to show a chart which represents the total orders per month of a customer.
You need not use stacked bar graph for this purpose.
You may want to use bar graph which would serve your purpose.
If you want to see the chart per customer, create one parameter $P{customer} and pass it into your query.
Refer document iReport-Ultimate-Guide-3 on how to create parameters and to use it in queries.
e.g:
select customer,month,count(orders)
from <your table>
where customer=$P{customer}
group by month
The above approach would work if you want to see the details for only one customer.
**Here is my solution after your update.**
From your update, it seems like you want to represent the total orders per month for all the customers.And you want to use stacked chart for the same.
Then what you have done is correct but have missed to add a field to your 'Series Expression'
Add your field customer to your series expression and this will resolve your problem i.e,
Series Expression : $F{customer}
Category expression : $F{Month}
Value expression : $F{count(Orders)}
This will display the chart in the format you have specified.
Create a paramter that takes your customer name $P{customerName}
and another takes month $P{month}
pass these two paramters to your sql like that
SELECT customer_name, order_count FROM customers
bla.. bla..
WHERE customer_name=$P{customerName} and month=$P{month}
then create a chart with only one serie to show one customer as one color. Not like yours with 3 colors.
Fell free to ask for more specific detail.

Access Crosstab or Form based on 2 tables with dates

There are a few answers here already that have part answered my challenge in Access but not fully.
I have 2 tables that form the basis of my database: customers and items
I have a further 2 tables; one for order quantities against customers and items (orders_a), and one for forecast quantities against customers and items (forecast_a).
forecast_a and orders_a also have a date for each customer and item combination (basically there will be 12 dates only for the 12 months of the year - 01/01/12,01/02/12,01/03/12 etc.)
Because a user will want to manually forecast quantities for a full year for each customer and each item, if there were 2 customers and 2 items, the forecast_a table would contain 48 rows. 2 items x 2 customers = 4, 4 x 12 dates = 48. The same goes for the orders_a.
I know this is a slightly unusual set up but the user requires visibility of a full year.
My main challenge based on this is as follows:
A user will want to see a form with customers in the first column, items in the second and then (like a crosstab): Jan Forecast Qty, Jan Order Qty, Feb Forecast Qty, Feb Order Qty etc.
Therefore how would I create a crosstab to pull both these tables together, and how would I go about creating a form for data entry off the back of it?
I may well be constructing my database the wrong way but the fact that the user needs a 'grid' where every entry is manual means I can't just have a form that creates a record one at a time for orders or forecasts.
Thanks in advance!
Nick
The problem you have is that this is a task that is in essence a spreadsheet task. Accordingly it may be best handled in Excel. To achieve this create an Excel object, create a blank worksheet, populate it with the data, then have a button to suck it back into the database when the user has finished.