PowerPivot fiter to slice data per hour, day or month - excel

I have an Excel database file that contains the total passenger passes from a specific location. The total number of passenger passes is counted in a period of 2 minutes(e.g. 14:45:00 to 14:46:59). I have imported my database into PowerPivot and have also created relevant PivotTables and PivotCharts with some slicers to analyze them. How can I create a slicer which filters data in greater periods of time like hour, day or month?

You'll need to create a Date/time table which contains all hours in your data.
First you'll need to create a calculated column in your original data that has the date and the hour
Formula to use:
=DATE(YEAR([Original Date]),MONTH([Original Date]),DAY([Original Date]))+HOUR([Original Date])/24
Result in your original data table
Original Date Calculated_DateHour
02/15/2015 14:15 02/15/2015 14:00
02/15/2015 16:25 02/15/2015 16:00
Now, in Excel create a Master Date table with unique date/time for all data
[DateTable]
Master_DateHour Year Month Day Hour
02/15/2015 13:00 2015 2 15 13
02/15/2015 14:00 2015 2 15 14
02/15/2015 15:00 2015 2 15 15
02/15/2015 16:00 2015 2 15 16
02/15/2015 17:00 2015 2 15 17
{...}
03/17/2015 02:00 2015 3 17 2
Next you'll create a relationship between the DateTable[Master_DateHour] (lookup table) and Data[Calculated_DateHour].
Now you should be able to slice based on the Year/Month/Day/Hour as you see fit.
Additionally, you could create a hierarchy in the [DateTable] to give you more control over the presentation of Year/Month/Day/Hour.

Related

Excel: calculate which occurance of a weekday, within the month, from any given date e.g. fifth Friday

I am not very good at Excel. In the NHS (UK) we often schedule activity by looking at the columns on a calendar (e.g. All day theatre list Mondays week 1,3,5). This means on the first Monday, third Monday and if present fifth Monday. Using a printed calendar you can see the columns, for example Mondays in Jan 2023 where there are five.
When planning, it would be great to have a formula that would accept a date, and return the ordinal of the weekday for that month e.g.
Jan 02 2023 = 1
Jan 28 2023 = 4
Jan 29 2023 = 5
Jan 30 2023 = 5
I have searched and found the WEEKNUM function, but this counts rows on the calendar not giving the result I need.
Any help gratefully received
Kind Regards Gavin Holt
This should return those values:
=-INT(-(DAY(YourCellWithTheDate))/7)

Reformatting Excel datastructure from multiple rows in columns/rows format

I have the following case: I got data in an format like:
date - timestamp - value where there are 29 values per day, so date stayes the same
What i need is something like:
date 1 per row
timestamp times 29 for each timestamp in a day as columns
values where date and timestamp meets
Is there a way to reformat the structure completely? As the data is pretty big (10 years, 29 data per day) it would take ages to do manually. I need it in the normal excel format as result so i can easily import the data in c#.
What i have:
22.03.2018 08:00 200
22.03.2018 08:30 202
22.03.2018 ...
22.03.2018 22:00 120
23.03.2018 08:00 12
What I want:
08:00 08:30 ... 22:00
22.03.2018 200 202 ... 120
23.03.2018 12
Every help would be appreciated :)
Br

Excel VBA - When 2 cells in a column are the same, add the 2 corrisponce number in the next column

I have three columns in my spreadsheet ID, Time and Height. What I want to do is run through the ID column and where the IDs match (Same ID occurs more than once in the list) sum the Height together for the earliest time (see example 2)
Example 1 (What I currently have)
ID Time Height
AB123 06:00 10
AD1234 10:00 10
AC12345 14:00 10
AC12345 06:00 10
AE123456 10:00 10
Example 2 (What I'm looking for)
ID Time Height
AB123 06:00 10
AD1234 10:00 10
AC12345 14:00 10
AC12345 06:00 20
AE123456 10:00 10
Within the sheet there may be 2, 2, 3 or 4 occurrence of the same ID number with multiple times.
I someone could help me with the VBA code for this I'd be very grateful.

Using SUMIFS to pull YTD sales data in excel

I am looking for a way to pull out YTD data for a spreadsheet that has the following in the A,B,C Columns.
I want it to be able to pull the current month of the year and compare YTD sales in the C column from that.
I have used =SUM(IF(YEAR(A:A)=2016,C:C,0)) to get the entire year data but want just jan - current month for each year listed.
YTD Sales Through May
2008
2009
2010
2011
2012
2013
2014
2015
2016
Jan-03 17 $86,625
Feb-03 17 $107,900
Mar-03 21 $103,400
Apr-03 17 $112,050
May-03 20 $75,145
Jun-03 26 $198,800
Jul-03 14 $80,695
Aug-03 19 $50,940
Sep-03 26 $152,380
Oct-03 23 $109,380
Nov-03 19 $113,875
Dec-03 21 $149,275
Jan-04 30 $113,110
Feb-04 17 $109,493
Mar-04 15 $69,690
Apr-04 25 $123,145
May-04 24 $136,685
Jun-04 30 $148,495
Jul-04 21 $138,990
Aug-04 29 $131,005
Sep-04 38 $165,790
Oct-04 43 $173,190
Nov-04 41 $253,915
Dec-04 39 $217,650
You would use this formula and change the Year to what you want:
=SUMPRODUCT((MONTH($A$1:$A$24)<=MONTH(TODAY()))*(YEAR($A$1:$A$24)=2016)*$C$1:$C$24)
If you want all the years YTD in one formula you can:
=SUMPRODUCT((MONTH($A$1:$A$24)<=MONTH(TODAY()))*(YEAR($A$1:$A$24)={2008,2009,2010,2011,2012,2013,2014,2015,2016})*$C$1:$C$24)
To make the formula more dynamic, so it grows and contracts with the size of the data use this;
=SUMPRODUCT((MONTH($A$2:INDEX(A:A,MATCH(1E+99,A:A)))<=MONTH(TODAY()))*(YEAR($A$2:INDEX(A:A,MATCH(1E+99,A:A)))={2004,2005})*$C$2:INDEX(C:C,MATCH(1E+99,A:A)))
Make sure that the references $A$2 and $C$2 refer to the first cell of data and not the title row.
With Array formula's calculations being exponential we need to limit the reference to only the dataset size. All the INDEX(A:A,MATCH(1E+99,A:A)) accomplish this. It will automatically set the last row with a number in column A as the last row of the dataset.
So as the dataset grows or shrinks we will not be doing any unneeded iterations.
Change {2004,2005} to any number of years desired.

List all the corresponding numbers which fall within a month

I have a table which looks something like this
Month Item Haul
June Gravel 23
July Asphalt 45
June Asphalt 5
June Asphalt 7
September Asphalt 26
October Gravel 17
June Asphalt 21
September Gravel 25
I want to create a function that will list all of the different "Asphalt" hauls which happen within a given month in another sheet so that I can calculate the tonnages of each haul. The result should look something like this
June
5
7
21
Is this even possible?
With a PivotTable (Month for ROWS , Item for COLUMNS and Haul for Σ VALUES) you can set Σ VALUES to calculate the average for you and if you want the detail for Asphalt and June just double click on that row/column intersect. The drill down will automatically open in another sheet and the PT will default to a separate sheet unless you choose otherwise.

Resources