Sorting error for Time row value in Pivot Table - excel

I've encountered an issue with a pivot table that I occasionally use, though I don't update. Specifically there are three Row Fields applied Year, Day (d-mon format), and then Transaction Date/Time (which displays only the hour component of the value). The pivot table is supposed to sort by Year, then Day, then Hour. The first two sorts work fine, but the third has started to sort the Hour values as text rather than numbers, so it's ordered 1 AM, 1 PM, 10 AM, 10 PM, etc. I've checked and there are no non-time values in the source field, the column of the pivot table itself is still set to a Time format type, and there are no filters applied to the field.
At this point I'm not sure what else to look for. Any assistance would be much appreciated.
UPDATE: The file is in Sharepoint so I tried taking the prior version (there are only two), dropping in the latest data from the current version, and refreshing the pivot table. The error dutifully appeared. So it does appear to be a data issue, but I can't imagine what's causing the issue. As stated above, I already checked that the values were Dates, specifically I used =IF(NOT(ISERROR(DATEVALUE(TEXT(C2, "m/d/yyyy h:mm"))), "", 1) and checked that all rows returned as blanks.
Something that may be causing issues is how the Year and Day fields come about. Specifically, there are no such fields in the Source Data, they are calculated Row Fields based on the one Transaction Date/Time column. I'm not even sure how this was done (to my knowledge calculated fields can only be columns) so I can't really look into if it may be causing the errors.

I also had this problem and found no good way around it in Excel. What I ended up doing (that worked for me) is to extract the 24hour "hour value" from a date field using =VALUE(TEXT(A2,"h")) (where A2 contains the time/date code I'm looking for). I then used the date code itself (Column A in this example) as the first Row Label (first grouped item) then added the "hour value" as a secondary Row Label/Group. This allows leveraging the Pivot Table sort/group function naturally and then adds the detail in the order I want.
I did not solve the problem for 12 hour display with AM/PM as this was good enough for my needs.

Related

Looker date pivot is not working as expected

I am having an issue with pivots by date. When I try to add a pivot by date it ends up stacking month over month.
All the percentages are correct for each month showing and they line up with the correct names but for some reason its stacking.
I did try to remove the date from the table and then add it as a pivot but for some reason I get this odd stacking behavior.
I suspect it might be due to the way the custom measures work since I have not seen this happen with a normal measure before.
See example:
Turns out the solution was to change the data in the view from a dimension to a measure and to change the type from a number to a sum.
After doing this to both fields I am using for creating the percentage it corrected the way the pivot was displayed.
Results:

Excel - A row in my Pivot table calculates sum wrongly only for some entries (same data type/format)

I created a tracker of learning hours in order to conduct an experiment.
For the purpose of the ticket, there is a time series that does not sum correctly data in Pivot table.
Some other tickets on Stack Overflow mention how to correctly sum. Here's what I tried:
considered blank spaces > the Pivot does not consider them anymore, yet the issue persist.
data type & format > the whole column is set for data type short date
labeling > I use to copy-paste the category for each learning and I double checked if there was no typo in them.
Here's how the file works. There are 3 sheet in my Excel file. The core of it is "Data" where I do track the time spent for each learning / exercise. The columns marked in red are the ones used for the next Pivot Table.
These information are consolidated in another sheet, called SuperLearner Review. I use this one to display overall learning hours by type and category. Numeric outputs here are looked up from Data (or calculated accordingly).
After several checks, I cannot retrieve the issue. All I know is that for February data are not tracked correctly.
Originally I attributed either to wrong data labeling or format, but I can manually see what is the real sum of learning done in February:
In the data-series those hours seem not to display. This is what the Pivot table returns instead:
Whereas, for the consolidated information (coming from the same source) does not seem there are problems in calculation:
When I tried to cancel and build up again the same Pivot Table, the same error occur. So I am not getting out of this wrong calculation. Therefore it must not be a problem of calculation, rather than Excel does not retrieve some data entries at one point.
What would you recommend? Thanks for the help.

How to filter data of last record of each week

I have a big data set of daily selling value of a particular ITEM. I want to know what was the price of ITEM on the last day of each week. Typically the last working day is Friday but if you don't have data for Friday then we need to get the previous working day data (Thursday).
Monday is considered the First day of week.
My Data looks something like this:
Data is in cells A2:C13.
My expected output is shown below:
Please help with VB macro or even simple excel formula.
You may want to try using a formula using the LOOKUP function, to search the list from bottom to top.
Afterward, a combination of INDEX and MATCH may get you on the right path as well.
Edit: I realize now that I was leading you astray because I thought you were asking something else! The most straightforward way I can see is as follows:
use WEEKDAY() to pull out the weekday values (as you did), except leave the values as numbers (with 1 being Sunday and 7 being Saturday).
Check each of these days to see if it precedes (i.e. has a lesser value) than the day above it. If not, we know that the week started over, and that cell is the last day of the week. Therefore, display its value.
Of course, this assumes that there are no Saturdays in your data - otherwise, Saturday would be listed as the end of the week. If you're crafty you can fix this dilemma though!
Thanks, Tyler.
Your suggestion helped me a lot in putting efforts in the right direction.
The way I did is as follows:
First I sorted my data in decreasing order of date so that I can have all the latest data at the top.
Range("AW4:BE999999").Sort Key1:=Range("BC4:BC999999"), order1:=xlDescending, Header:=xlYes
From Date created a string of "YEAR"&"WEEKNUM". This way I was able to group all the days in a specific week. Formula Used is:
=(TEXT(BC5,"yyyy"))&(TEXT(WEEKNUM(BC5),"00"))
Then I gave a unique Number to each record. The best way I could think of is to give the row number where record belongs.
=ROW(AY5)
Now using VLOOKUP function I got all the records matching string I have created in step 2
=VLOOKUP(AZ5,AZ:BD,5,FALSE)
I applied the above formula to get all the columns that I need.
Now I removed all the duplicate rows using below formula:
Cells.RemoveDuplicates Columns:=Array(1)
Now the remaining rows are the expected rows.
There may be a better way to do this but this is my first time with excel macro and formulas, so feeling happy.
Please comment other better ways to do this. It's always good to keep on improving our work.

Excel 2011 Consolidate Duplicate Rows (MAC - "Scripting.Dictionary" doesn't work)

I'm stuck with a fairly finicky data report that I don't have the option of customizing at all, that I would like to prepare in such a way to make my life easier. I am using Excel 2011 on a Mac. (This is for student attendance)
I've been searching all over the web for days and tried multiple different methods, even the most promising of haven't worked. The closest approximation (Combining duplicate entries with unique data in Excel & the one linked in comments) runs into problems with Scripting.Dictionary not being a thing on Macs?
Right now I'm filtering the data, turning that into a pivot table and then manually cross-referencing the pivot table count and the filtered data dates & sessions and tracking new absences by pasting them into a "master list."
It doesn't work well. Its both time consuming and students fall through the cracks.
Information (Columns) I have:
Student,
Course,
Course start,
Course end,
Attendance date,
Session (AM or PM) and
attendance (Present, Absent, Late, Left Early, Excused, Explained)
We meet with students after a certain number of absences and lates - but if they are absent for both morning and evening session it counts as a single absence (lates both count)
At a minimum, I would like to consolidate the AM and PM row for "absent" and "explained absent" occurring for the same student on the same day into one row, instead of spread across two so I can just count rows (explained, absent, late, and left early) instead of count and then manually track and compare. (conveniently, the classes are all entire day classes, and there is no date overlap for any single student. Less conveniently not all attendance sessions are entered, so there is no pattern to base things on.)
Priority 1: Consolidate AM & PM into one row when appropriate
- Consolidate Rows so that Session becomes "AM, PM" instead of AM & PM across two rows for "Explained Absence" "Excused Absence" and "Absence" ONLY. (Student, Course, date and attendance need to all be identical)
- Where attendance is "late", "left early" or different for the morning and evening session, the lines should NOT be consolidated.
Goals
- minimal steps, every time I do this I have to generate a new report, and I'd like to change this from an all day task to something I can do more frequently.
- End result needs a count as described above and a list of the days and sessions missed, so pivot tables are not ideal as they erase the specific data.
I am comfortable with inserting and light tweaking of VBA, but am not fluent in it by any stretch.
Example:
Student, Course, Course Start, Course End all consistent in this example. Not included below because it becomes too unwieldy....I give up on making this a table. Sorry.
Attendance Date Session Attendance Manual "strikes" count
17-12-04 PM Present 0
17-12-04 AM Late 1
17-12-06 AM Absent 2
17-12-06 PM Absent 2 (absent also above)
17-12-07 AM Late 3
17-12-07 PM Absent 4 (different types)
17-12-08 AM Late 1 (new course)
17-12-08 AM Late 2 (two lates)
Have you tried using Data > Data Tools > Remove Duplicates? If you select the entire table, this method allows you to choose multiple columns for the "remove duplicates" function.
Try this. I used the PivotTable option PivotTable Tools > Options > Calculations > Show Values As > Index, which seems to remove duplicates during PivotTable reporting.
When I added a Row Labels PivotTable field that makes same-same rows unique, (such as "AM" or "PM" in your example), this "Show Values As Index" method did not remove duplicate rows.
Also, I'm using "Date Filter, This Week" on the Date dropdown-list to just show the dates I'm interested in.
Good luck!

Creating a sum based on a category within a date range

I'm trying to make a spreadsheet that I can easily take an export from Mint.com's CSV outputs and get them into my Excel budget.
To do so, I need a way to populate each field within a date range. I'd like to avoid macros if possible (I don't know how to make them).
I'm happy to share my finished .xls with the public!
I've imported Mint.com's data in a manner that has column S for the date (3/30), column V with the cash value that I need to add up, and column X for the spending category.
I need to tally each month's spending ($V) by category (column X).
Through research, I devised this (for my January "Gas & Fuel" spending):
=SUMIFS($W$2:$W$900, $T$2:$T$900, ">="&W$12, $T$2:$T$900, "<"&(EOMONTH(D$1,0)+1), $Y$2:$Y$900, "="&$B5)
However, it required that I reformat my Dates, which is an issue because this would become specific to each year and I would need to change the fields every year. I'd like the document to be usable without adjustment using my spending data from the past and future.
Is there a way to take the year out of the equation? To make that formula above work, I renamed my column from "January" to "1/14".
Here is what the spreadsheet looks like
Thanks!
A pivot table would work best with that data.
Initial set up would show each day separately, but by using Grouping
(here) ^^^
you can group the data by month/day/year/however

Resources