How to group by ID and find gaps in dates to determine start and end date in Alteryx? - alteryx

I have a dataset that looks like the following;
ID Date
1 2018-07-23
1 2018-07-24
1 2018-07-25
1 2018-07-26
1 2019-12-31
2 2020-01-01
2 2020-01-02
2 2020-01-03
2 2020-01-06
2 2020-01-07
What I am trying to achieve is convert this dataset into start and end dates for wherever their are any gaps in the date column.
So the expected output would look like the following;
ID StartDate EndDate
1 23-07-2018 26-07-2018
1 31-12-2019 31-12-2019
2 01-01-2020 03-01-2020
2 06-01-2020 07-01-2020
As you can see, both IDs have two rows because there was a gap in the dates.
Please Help and thank you.

For StartDate: use the MultiRowFormula tool. In its options, Group by ID, tell it to default to the value of the nearest row, and use an expression something like:
IIF ([Date] == DateAdd([Row-1:Date],'days',1) THEN
[Row-1:StartDate]
ELSE
[Date]
ENDIF
That will create all the [StartDate] for you, but you'll still have multiple rows. So, then do an Aggregation tool: Group by both ID and StartDate, and create EndDate as max([Date]). That should provide the correct EndDate to go with each StartDate.

Related

Select records with at one day in centain year

I want to make a selection of records where date range (start date - end date) includes at least 1 day of 2020. So for example: if a record has 2018-01-13 as the start date and 2020-01-09 as end date, it has to be included in my selection, as there is at least one day active in 2020.
Sample data:
How can I achieve this?
Just check the years with the standard between notation
Start Year <= 2020 <= End Year
=AND(YEAR(A1)<=2020,YEAR(B1)>=2020)
=IF(OR(YEAR(A2)=2020,YEAR(B2)=2020),1,0)
Excel store dates as numbers, so, you must compare them like numbers
Make a column with: =IF(OR(B2 < $C$2; $D$2 < A2); 0; 1)
where
A: start date
B: final date
C: 2020-01-01
D: 2020-12-31
, Now you can use only values 1

Calculate 3 month Average on the base of CustomerID

I am trying to calculate three month average sales in excel w.r.t customerid in excel. I tried by doing it by AverageIfs function but nothing helped.
A B C
Orderdate sales customerid
5/15/2019 7 1
5/15/2019 48.5 1
4/15/2019 92.94 1
3/17/2019 102.85 1
3/18/2019 49 1
3/18/2019 119.95 1
2/18/2019 58.96 1
1/20/2019 14.6 1
5/16/2019 17 6
4/15/2019 148.5 6
4/12/2019 912.94 6
3/17/2019 102.85 6
9/18/2018 22.34 6
Formula I tried: =AVERAGEIFS(B:B,C:C,C2)
output expected:
customerid average(3 months)
1 49.48
6 359.48
Let's start from today's date and the date 3 months ago (Make it dynamic):
Remember to change the cell format from General to Date. Otherwise, it will show [43563]
Next use the date as part of our filter:
Now you should get the most recent 3 months data:
Copy the filtered data into a new spreadsheet
Copy the filtered data into a new spreadsheet
Copy the filtered data into a new spreadsheet
Next Step: get the distinct customer ID:
You will get this:
Last Step:
Use the function "AVERAGEIF":
Done!

How to get latest 3 months data by default from complete data set

I have a full year data set and I have developed a power bI report on it and I scheduled it.
I need to show up last 3 months data every time.
Column a column b column c
a 1 2019-01-01
b 2 2019-02-01
c 3 2019-03-01
d 4 2019-04-01
e 5 2019-05-01
I am trying to get last 3 months data from above table by using hive query without hard coding the month name or month number in where condition.
like by using this kind of date function.
select add_month( month, max(month(COLUMN C)),-3) from tableA
Its add_months
select * from tableA where columnc > add_months(columnc,-3)
if the columnc is not a string then cast it
select * from tableA where (cast(columnc as string),'yyyy-MM-dd') > add_months((cast(columnc as string),'yyyy-MM-dd'),-3)

Convert timestamp to date in Excel pivot table

I have a pivot table which currently looks like this:
No of Sales
Team 1
2017-03-10T07:10:20.289Z 1
2017-03-10T07:10:22.289Z 4
2017-03-14T07:08:20.289Z 10
Team 2
2017-03-11T07:14:20.289Z 11
I want to group by the date in the timestamp and only show the date and the total for that day so it looks like this instead:
No of Sales
Team 1
2017-03-10 5
2017-03-14 10
Team 2
2017-03-11 11
How can I do this?
you can do the rest of the code, but the important part is:
strTemp= cells(row, col).value 'this contains the date 2017-03-10T07:10:20.289Z
strDate = split(strTemp, "T")(0)
That's it.

How to find values in one column in another column with multiple values

I have an excel like
A B START DATE END DATE
1 10 01-jan-2016 02-jan-2016
2 11 01- jan-2051 02-feb-2061
3 1 04-mar-2016 07-mar-2016
4 1 08-mar-2016 10-mar-2016
5 5 01-mar-2016 03-dec-2016
6 5 03-nov-2016 31-dec-4712
I am new to excel. I want to highlight or extract the columns in A column which can be found in B Column along with the start date and end date .
That is result should be like :
A start_date end_date
1 04-mar-2016 07-mar-2016
1 08-mar-2016 10-mar-2016
5 01-mar-2016 03-dec-2016
5 03-nov-2016 31-dec-4712
Can anyone pls suggest something ?
In E2 enter:
=IF(COUNTIF(A:A,B2)>0,"X","")
and copy down. Then filter the table
You can hide any un-wanted columns after that.

Resources