How to count just a first sale by a client in tableau - tableau-api

I have a spreadsheet with clients first purchase I want to see how many new clients a month we are getting. However some of the clients we sell too could have the same name in a different zip code for example miami clinic could be in both florida and ohio so I want them counted individually. I also want to see the total new clinics per month. but if a clinic purchases in january and again in march i only want that january purchase counted

Let us assume your sample data be like
Now create a calculated field first purchase date as
{Fixed [Clinic Name], [Zipcode]: min([Sale Date])}
This field will give each clinic its first purchase date only. Check it
Now to create a filter for first purchase date create a calculated field say first purchase filter as
[first purchase date] = [Sale Date]
Adding TRUE value filter (and don't forget to add the filter to context by right clicking it) will give sale amount in first purchases
OR use this filter for differentiation also
For any further query please share your actual data structure with a few rows and desired output in respect of those sample rows.

Related

(Google Sheets) How do you get cells to alter based on a certain date?

I'm looking to create a spreadsheet to get a grasp of what my personal finances are saying. Part of this obviously involves putting in income from my job. While I know my shifts in advance so I know how much I will be earning on any given day, I won't actually get the money until the end of the month.
I've created a cell called 'bank balance' based on my current savings, but obviously I don't want to have to physically update this every time I get paid so I'd like to just be able to give Sheets a date where it can update that cell itself based on my payday.
For example:
I start off with £100 in my bank account on January 15th. I know I'm going to get paid £400 on January 28th (last working day of the month). I don't want to input that on Jan 15th as that wouldn't be an accurate reflection of my finances. So I input something that tells sheets to add that £400 on to the bank balance cell on Jan 28th for me.
[The example sheet on January 15th]
[The example sheet on payday January 28th after automatically adding on the £400 to the bank balance]
I've currently got a separate cell for 'work income' that I want to apply this function to (I.E. so that I can tell the sheet to add the total 'work income' to 'bank balance' on payday) but I'm not sure where to go from here.
I've got similar issues with subscriptions leaving my account on various days of the month but the income is my higher priority.
Any help with this would be greatly appreciated

Cohort on Tableau

Is it possible to do cohort on tableau? how would I see cohort of first time purchase if I only have name of customer, date of sign up, date of first time purchase. I want to see the relation between sign up and purchase on cohort.
company_name signup_date approval_status approval_date first_paid_plan first_paid_plan_date
I think you'll like what you find here: https://www.tableau.com/about/blog/LOD-expressions

Change date from calander date to date since first record in tableau

So, pretend I'm looking at sales of an item vs time. One item I started selling 3 years ago and one is from only a year ago.
I want to look at how the performance of both items change starting from first date sold as "day 0" not from first date sold as say "march 2016".
My date field is a calendar date and I'm not sure the best way line everything up from within tableau that will allow me to display the result on a single graph. I'd also like an option that will scale to 10+ items
Any approaches would be great!
Create a calculated field called first_Sale_date_per_item defined as {fixed Item : min(sale_date)}
Then you can define days_since_first_sale as datediff('day', first_sale_date_per_item, sale_date)

Reporting and filtering dates in access 2007?

I'm having a customer look up a report between FROM and TO dates. Basically for any month a client can request a report, what I need to do is show the QTY of units in the inventory as of the last day of previous month. So if client is looking to make a report for 12/23/2015 - 12/28/2016 then I need to show the QTY of units in inventory (beginning inventory) on 11/30/2015. I had someone recommend I use DateSerial, but it doesn't seem to do what I want it to do. Basically the FROM AND TO dates are values that I pass on from a Visual Basic application into an empty form and they get used in the report.
I'm not sure if I need to make changes to my queries. Here's what the report does..
With the report, I need to be able to show the client the following...
ItemID
Beginning Inventory (as of last day of previous month)
Unit Price
Bought Units (for report date)
Sold Units (for report date)
Returned Units (for report date)
Subtotal (of bought +sold+returned)
Inventory on hand (beg + subtotal)
So what I do is in my first query I get the Unit Price, and Beginning Inventory (currently not filtering by last day of previous month).
Then I have 3 more queries, one for Bought, Sold and Returned where I link the ItemID's and I filter the TransactionDate (between dates form!formdates!txtFrom and form!formdates!txtTo).
Then I have the last query where I combine the first one with the other 3. Now I'm pretty sure I should include the DATESERIAL() function in the first query? And filter the TransactionDate (this is the column i need to look through to count beginning inv, as well as look for Bought, Sold, Returned Items).
Please help!
The DateSerial() function should return the last day of the previous month. Here is an example query for your problem:
SELECT ID, myDate
FROM Table1
WHERE (((myDate)=DateSerial(Year([enter start date:]),Month([enter start date:]),0))) OR (((myDate) Between [enter start date:] And [enter end date:]));
Documentation: https://msdn.microsoft.com/en-us/library/bbx05d0c(v=vs.90).aspx

Counting Unique records by Month in Tableau over a year

I have a list of product codes and their sale dates. I want to only count the first ever sale of that product, then SUM the first sales by month of sale.
So if Product A was sold in Feb, Mar and Nov, it only gets counted in Feb.
Here is a badly copied table
Product Code Sales Date WHAT I WANT
-------------------------------------------
A1234 01/02/2014 COUNT THIS
B3333 03/02/2014 COUNT THIS
C5555 06/03/2014 COUNT THIS
A1234 09/03/2014 DON’T COUNT
F567 15/04/2014 COUNT THIS
P000 25/05/2014 COUNT THIS
B3333 01/01/2015 DON’T COUNT
A1234 06/01/2015 DON’T COUNT
P000 19/01/2015 DON’T COUNT
B3333 26/01/2015 DON’T COUNT
K5678 20/02/2015 COUNT THIS
I want my end result to be a graph with months down the side and then a count of first times a product is sold.
Does this make sense? I tried using MIN, but it makes everything AGG, which stops you comparing a date with a date.
UPDATE: commenter pointed out there were two questions in the initial question. Both would be answered with an LOD.
To answer the question: "I want my end result to be a graph with months down the side and then a count of first times a product is sold."
Use a Fixed formula:
count(if
DATETRUNC('month',[Sales Date])={fixed [Product Code]:min(datetrunc('month',[Sales Date]))}
then
[Product Code]
END)
This formula compares the month of the date at each row level to the minimum date for all sales of that same product code. Then it counts up the records where this condition is true.
To answer the question: I want to only count the first ever sale of that product, then SUM the first sales by month of sale.
Since the OP didn't provide sales #'s in the original table I didn't answer the sum part of the question. However, this would also be an LOD and it would look like:
sum(if
DATETRUNC('month',[Sales Date])={fixed [Product Code]:min(datetrunc('month',[Sales Date]))}
then
[Sales]
END)
This is very similar to the above except it sums up sales instead of counting products.
And here is a picture (I added sales and one extra row of sales for product A1234 so you can see that it gets summed as part of the product's first months sales.)
To deep dive into the LOD (Level of Detail) part of this, {fixed [Product Code]:min(datetrunc('month',[Sales Date]))}, Tableau allows you to do calculations based on a specified scope. In this case, the formula gets read like "return the minimum date's month of the sales date for each product code". You can read much more about LOD's on Tableau's site or many Google search results.