Turnaround time within continuous dates starting from today - days

I have a table called Sales and it looks like this:
Item.....SaleDate..
-------------------
A........2017-08-11
A........2017-08-10
B........2017-08-11
B........2017-08-10
A........2017-08-09
A........2017-08-01
A........2017-07-31
C........2017-06-01
D........2017-08-11
What I am trying to get is the number of continuous days an item is sold ending with today (2017-08-11)
So in this case the result set should be
Item.....Days..
---------------
A........3 (from 9th to 11th)
B........2 (10th and 11th)
D........1 (only 11th)
(and no record of C because there was no sale on the 11th)
No matter what I tried I cannot seem to get the final result.
Help is greatly appreciated.

Related

How to get a YTM calculation instead of YTD in Google Data Studio

I have an earnings table in my Google Data Studio report from January 21 - YTD.
But what i want is a table that shows me YTM (so this year until last month) Jan-21 til Sep-21 and that dynamicly on 1st Nov, Okt-21 is added to the table, and on 1st dec Nov-21
is added etc.
Because the Total YTD value is other wise too high, due to cost being booked at the end of the month and earnings through the month.
Filters wont let you do it dynamicly,
date range filters same,
always possible to do it manualy with date range but this i cannot ask from my client.
any suggestions??
Kind regards
I found the answer,
i left the question for when someone else wants to do it,
it is actualy simpel fixed by using advanced date filter and then leaving the start date on 1-jan, and end date to today minus 1 month.
this gave me the exact result i needed yt last month

Is there a way to consolidate multiple formulas into one

all:
I am trying to design a shared worksheet that measures salespeople performance over a period of time. In addition to calculating # of units, sales price, and profit, I am trying to calculate how many new account were sold in the month (ideally, I'd like to be able to change the timeframe so I can calculate larger time periods like quarter, year etc').
In essence, I want to find out if a customer was sold to in the 12 months before the present month, and if not, that I will see the customer number and the salesperson who sold them.
So far, I was able to calculate that by adding three columns that each calculate a part of the process (see screenshot below):
Column H (SoldLastYear) - Shows customers that were sold in the year before this current month: =IF(AND(B2>=(TODAY()-365),B2<(TODAY()-DAY(TODAY())+1)),D2,"")
Column I (SoldNow) - Shows the customers that were sold this month, and if they are NOT found in column H, show "New Cust": =IFNA(IF(B2>TODAY()-DAY(TODAY()),VLOOKUP(D2,H:H,1,FALSE),""),"New Cust")
Column J (NewCust) - If Column I shows "New Cust", show me the customer number: =IF(I2="New Cust",D2,"")
Column K (SalesName) - if Column I shows "New Cust", show me the salesperson name: =IF(I2="New Cust",C2,"")
Does anyone have an idea how I can make this more efficient? Could an array formula work here or will it be stuck in a loop since its referring to other lines in the same column?
Any help would be appreciated!!
EDIT: Here is what Im trying to achieve:
Instead of:
having Column H showing me what was sold in the 12 months before the 1st day of the current month (for today's date: 8/1/19-7/31/20);
Having Column I showing me what was sold in August 2020; and
Column I searching column H to see if that customer was sold in the timeframe specified in Column H
I want to have one column that does all three: One column that flags all sales made for the last 12 months from the beginning of the current month (so, 8/1/19 to 8/27/20), then compares sales made in current month (august) with the sales made before it, and lets me know the first time a customer shows up in current month IF it doesn't appear in the 12 months prior --> finds the new customers after a dormant period of 12 months.
Im really just trying to find a way to make the formula better and less-resource consuming. With a large dataset, the three columns (copied a few times for different timeframes) really slow down Excel...
Here is an example of the end result:
Example of final product

Calculation of Night shift hours

I am stuck with an issue, I have to create an attendance system where I have an employee id and punching time.
There can be multiple punches in a day. So firstly for night shift employees I can't determine his actual in and out time and thus not the duration too.
For example a person came office at 11 pm on 1st April and left at 4 am on 2nd April. In between he also went out for dinner or tea .
I don't have a fixed number of punches. And I need to handle 2 dates as well. So min and max logic wont work.
The major problem is there are multiple punch-ins and row_number wont work as punches are of 2 different dates in case of night shift.
here tktno is employeeID , date is the punching time and sno, is number of punches in a day. I have sent you a sample data of a night shift employee.
I require data in given below format -
But here as you can see the hours calculation is not correct . I want to correct it .

Short Formula To Pull Upcoming Holidays For a Title Merge In A Huge Database

I am Using excel 2007 and running Windows 7 Pro. I have 50 Thousand rows with data.
I am trying to do a formula that gives me a value of the next upcoming holiday. I have 4 columns of holidays.
For example: Today's date is 6/3/2015 next upcoming holiday would be Father's Day and after that would be Halloween.
So, from Today's date to Father's Day the value would contain "Father's Day"
After Father's day, I want the formula to automatically replace "Father's day" with "Halloween" And doing the same to upcoming holidays after that.
I have researched forums and gotten ideas to compose a formula. I was able to create one, but the only way I got it to work was with the holiday's date instead of there name. If there is no other way of doing it besides that way I would be okay with it.
Only thing i'm concerned about is Opening, Saving, and Editing a file that large with a formula that big is very time consuming and unresponsive sometimes. I need help and would like to have a formula that dose what I need more efficiently and quicker.Any Ideas on shortening the formula?
Here is my formula:
=IF(SMALL(IF($A$2:$D$2>TODAY(),$A$2:$D$2),1)=DATE(YEAR(TODAY()),2,14),"Valentine's Day",IF(SMALL(IF($A$2:$D$2>TODAY(),$A$2:$D$2),1)=DATE(YEAR(TODAY()),4,5),"Easter Day",IF(SMALL(IF($A$2:$D$2>TODAY(),$A$2:$D$2),1)=DATE(YEAR(TODAY()),5,10),"Mother's Day",IF(SMALL(IF($A$2:$D$2>TODAY(),$A$2:$D$2),1)=DATE(YEAR(TODAY()),6,21),"Father's Day",IF(SMALL(IF($A$2:$D$2>TODAY(),$A$2:$D$2),1)=DATE(YEAR(TODAY()),10,31),"Halloween",IF(SMALL(IF($A$2:$D$2>TODAY(),$A$2:$D$2),1)=DATE(YEAR(TODAY()),12,25),"Christmas"))))))
I have dates in Array A2:D2
I have two differnt ways i can lay out my data. One way is with the holiday's name, and the other is with the holidays date. Examples are shown below... My formula displayed above is created to work with the first example below.
A B C D
2/14/2015 6/21/2015 10/31/2015 12/25/2015
OR
A B C D
Mother's day Father's day Halloween Christmas
I need it to read A-D search for the next upcoming holiday and return the value.
Thanks in advance for any help, tips, and ideas.
If the dates and names for the corresponding holidays are set up as such:
A B
2/14/2015 Valentine's Day
4/5/2015 Easter Day
5/10/2015 Mother's day
6/21/2015 Father's day
10/31/2015 Halloween
12/25/2015 Christmas
This formula can work to get the next holiday from today's date.
=INDEX(B2:B7,MATCH(TODAY(),A2:A7,1)+1)
If the names for the corresponding holidays are not within the list. You can hardcode them in the INDEX formula. Replace the first parameter with an array of hardcoded days, i.e:
{"Valentine's Day","Easter Day","Mother's Day","Father's day","Halloween","Christams"}
Even if we have the dates in a horizontal range, lets say A1:D1 we can still hardcode the days in an INDEX as such:
=INDEX({"Mother's Day","Father's day","Halloween","Christams"},MATCH(TODAY(),$A$1:$D$1,1)+1)

SSAS -> AdventureWorks Example -> Using the browser to splice a measure by week, shows results that have two of the same week records?

I have been working on a cube and noticed that when I am browsing measures in my cube by weeks, I am getting an unexpected result, but first let me display my current scenario. I am looking at counts of a fact load by weeks. When I do so I am getting results like these. :
Weeks | Fact Internet Sales Count
2001-07-01 00:00:00.000 | 28
2001-07-08 00:00:00.000 | 29
....and so on as you would expect.
Further down I noticed this. :
2001-09-30 00:00:00.000 | 10
2001-09-30 00:00:00.000 | 24
As you can see, it shows the week twice with different counts, when you add these counts together it is the correct number of counts for this week (i.e. 34).
I am just confused why it is showing two weeks, when I look at the data in sql I can see that the difference in data between these two is strictly the month in which these dates fell (10 in the earliest month and 24 and the later month in any example).
I initially saw this in my original cube that I created on my own, in turn, I pulled up trusty adventureWorks practice cube and found that it was present in that cube also.
This is due to the fact that within this date hierarchy, the lowest attribute in the hierarchy was date not week. Therefore, there was always a split for weeks by date. This can be alleviated by making a date hierarchy with week as the lowest portion of a date hierarchy.

Resources