Convert timestamp to date in Excel pivot table - excel

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.

Related

In Excel how do I find a column then sum between two dates?

In excel I have a pivottable:
Project
11/1/2021
11/2/2021
11/3/2021
Dept 1
5
5
5
Dept 2
2
5
5
Dept 3
5
4
6
Dept 4
5
3
5
The table spans the full length of the month. I need a calculation that would find the department I input then sums all figures between today's date and the last day of the month:
Dept
Total
Dept 1
15
I have tried
=SUMPRODUCT(((Today()<=B1:K1)*(EOMONTH(TODAY(),0)>=B1:K1))*(A2:A5="Dept 1")*(B2:K5)
and various different vlookups but I can't figure out how to both find the correct row and then sum everything between the two dates in that row.
Assuming the following structure:
Try this, it works:
SUM(INDIRECT(ADDRESS(MATCH($B$2,$A:$A,0),COLUMN($B$6))&":"&ADDRESS(MATCH($B$2,$A:$A,0),MATCH($B$3,$6:$6,0)),TRUE))

How to group by ID and find gaps in dates to determine start and end date in 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.

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 create a ranged frequency table using Excel Cube functions

What I want is to create something like this (see image) in Excel that pulls in the frequency of my chosen category from a table within my PowerPivot data model. The output would also need to be dynamically filtered via a cell reference.
Using the below data set as an example:
Week 1 A
Week 1 A
Week 1 A
Week 1 A
Week 1 A
Week 1 B
Week 1 B
Week 1 C
Week 1 D
Week 2 A
Week 2 A
Week 2 A
Week 2 A
Week 2 A
Week 2 A
If I filtered to Week 1 through my set expression, the following output would be produced
1 2
2-4 1
5+ 1
However, if filtered to Week 2, this output would be produced
1 0
2-4 0
5+ 1
I say 'set expression' because I am assuming the way to do this is through the CUBESET function possibly with a MDX FILTER function and the CUBESETCOUNT functions though I am open to other suggestions. Even though the example doesn't show it, I need the expression to filter multiple dimensions from my cube, in particular, date, which is found in my calendar table.
I also understand that I could create specific measures within PowerPivot to handle this (sample formula below), but I would like to know if this is possible via the CUBESET function.
Freq (5+):=CALCULATE(
DISTINCTCOUNT([myColumn]),
FILTER(myTable,
COUNTROWS(FILTER('myTable', [myColumn] = EARLIER([myColumn]))) >=5 )
)
I am also open to creating a helper column within my Powerpivot table.
Thanks,

Excel: Count billing hours for specific month, week, year

I have four columns in a spreadsheet, Month, Week, Year, Hours and I want to 'sum' the number of hours based on the month, week, and year number. Months would be (1-12), week would be (1-52), and year would be (2009, 2010, 2011)
For example:
Month Week Year Hours Total_Hours
1 2 2011 8 12
1 2 2011 4 12
1 2 2010 7 7
1 2 2009 5 5
Not sure if I should use vlookup or a nest 'if'. If someone else has a better approach, please let me know.
Thanks in advance.
First, you create another column that is a string concatenation of the first three, and drag down:
=TRIM(A2) & TRIM(B2) & TRIM(C2)
Then, you use this formula for Total_Hours, and drag down:
=SUMIF(D:D, D2, E:E)
My example uses your sample, and inserts a new column D for the concatenation.
End Result:
Month Week Year Concat Hours Total_Hours
1 2 2011 122011 8 12
1 2 2011 122011 4 12
1 2 2010 122010 7 7
1 2 2009 122009 5 5
Of course, I'd use Named Ranges for anything that's likely to change.
If you use VLOOKUP ensure the textual data is formatted correctly or use Text and Data functions

Resources