Sorting and arranging data Excel - excel

Alright I have searched and google'd.. I have an excel spreadsheet for each day of the week. In this spreadsheet the information that is logged is as follows:
1. Did the ambulance come available on time? If not, how many minutes early or late?
2. Who was the crew, and what was the reason for being late.
What I'd like to do in a separate sheet is search the data and print anyone that has been late more than one time. I'd also like to add the amount of time they've been late accumulatively for that week.
I'd also like to do the same thing for the people that are coming available early and add the amount of time they've added by doing so.
What I've done so far is add a few IF statements in a separate row. IF(J17 = "Late Sign-On", "Check", ""). This has helped me know who is late but it's kind of adding more work since it is already recording who is late etc.
Any help would be appreciated!

Without any idea of your data and how it is laid out I have built an example of the use of SUMIFS() below.
The Names is the list of all the names you have and this and the calculation can be on a separate sheet.

Related

Excel date formulas

I am really struggling with excel, if this is easy then I apologize, but I'm very new to using excel so clear instructions would be really helpful.
The task I'm trying to achieve is creating a spreadsheet to track the dates of some safety checks on equipment.
I have columns for the equipment name (which doesn't change), and the name of the person who checked it, which needs to be filled manually, I am trying to use a formula to automatically input the date of check (the current date) and the date the next check is needed (3, 6, or 12 months from the current date depending on the piece of equipment in question). I have tried using the TODAY() function, and TODAY()+X(number of days), but these change every day which is not what I want, is there any way to have excel automatically calculate and fill these dates, but then not change them until a particular cell (i.e. name of person who checked) is updated?
I know about setting calculation to manual, but that stops calculations even when new data is entered, I need to be able to update the sheet, and have existing dates remain unchanged (hoping that makes sense).
And again, very new to excel, so please make answers as easy to follow as possible.
Any help would be greatly appreciated, all the best.
Simplest solution (that works on all machines):
Ctrl+;
ref : https://stackoverflow.com/a/31771724/7602468
Official OEM solution :
Use Worksheet.Change event in your VBA code.
ref : https://learn.microsoft.com/en-us/office/vba/api/excel.worksheet.change
Credit :
#Euler's Disgraced Stepchild
#Tom Sharpe
#Gary's Student
Please share if it works/not..
Here is a page that can help. Scroll to
Creating a Custom Function to Insert Timestamp

Dynamically generate list of payment dates considering first/last date and client - ideal for controlling receivables of SaaS and recurrent contracts

I'm building an accounts receivable sheet in Google Sheets.
I would like to register the clients and their contract characteristics (client, payment frequency and price) in one sheet and I would like to dynamically generate the payment dates in another sheet.
The input sheet would look like this:
The output sheet would look like this:
I think it might be something in the QUERY and ARRAYFORMULA universe but I don't know how to configure it. Is there a way to dynamically generate the combination of Date and Client, taking into consideration first and last payment dates?
Sample in this link. If you'd like to use, please fill free to create a copy for yourself and post it in your answer.
Creating a 2D array of concatenated strings of dates and values can be a good first step in these kinds of problems.
I've demonstrated the idea in a tab called MK.Help on this sheet that I also shared in the comment above. This formula can be found in cell A2 and is generating the whole list:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(Input!A2:A5&"|"&Input!D2:D5+SEQUENCE(1,CEILING(MAX(IFERROR((Input!E2:E5-Input!D2:D5)/Input!C2:C5))),0)*Input!C2:C5&"|"&Input!E2:E5),"|",0,0),"select Col2, Col1 where Col2<=Col3 order by Col2"))
Once you have the data in a big 2D array, you can flatten it out and then split it into it's component parts to make it query'able. I've tried to outline the process to the right of the solution.
#MattKing's answer was really good but I particularly had problems since all my inputs would have dynamic sizes and doing his step by step I couldn't figure how to adapt to this situation.
So, using a lot of Matt's inspiration and some extra research (including this new question) I came to a solution that worked better for me, using multiple pages to come to a final result. Not so classy but works.
I left my solution available in this sheet.
Even though, I've chosen to accept Matt's answer since it worked, it helped me, it looks "more pythonic" and maybe the need to be so dynamic wasn't so clear in the question.

I've reached the max number of IF statements, and need help to optimise my formula

I am creating a spreadsheet to reconstruct an HTML export into an editable daily schedule.
The export contains info on what each person is scheduled to do throughout the day, and the spreadsheet turns it into a format with hourly columns.
Source data: https://imgur.com/6MAtxLA
Output: https://imgur.com/OI9RKC9
To do this, I've broken down what each person is doing into separate start and end columns, and used nested IF statements to piece it together.
The issue is that I've come up against the maximum amount of nesting, and I still need to add more, as there are more activities to cover. I'd like to know if there's another way I could go about it which wouldn't cause this issue.
The formula looks like this:
https://imgur.com/0R3FDhd
It's just saying that if the activity is on or before the current time, and hasn't ended yet, then it should show that activity.
Each line references a type of activity. The referenced cells look like this:
https://imgur.com/wjipfLT
There's a lot of repetition in the formula, and I hope there's a way to handle it so that each type of activity doesn't need it's own IF statement. However, I'm kind of stuck here. If there's anyone who knows a way I could change this, I'd really appreciate the help.
EDIT: Formula
IF(AND(OR(P[#6]=X!Z4, [#M]=X!Z4), S[#5] <> X!Z4), X!Z4,
IF(AND(OR(P[#6]=X!Z5, [#M]=X!Z5), S[#5] <> X!Z5), X!Z5,
IF(AND(OR(P[#6]=X!Z6, [#M]=X!Z6), S[#5] <> X!Z6), X!Z6,
...ad nauseam

How to optimize COUNTIFS with very large data

I would like to create a report that look like this picture below.
My data has around 500,000 cells (it will continue to grow larger)
Right now, I'm using countifs function from excel but it takes a very long time to calculate. (cannot turnoff automatic calculate)
The main value is collected as date and the range of date is about 3 years, so I have to put a lot of formula to cover all range of value.
result
The picture below is the datasource the top one cannot be changed. , while the bottom is the one I created by myself (can change). I use weeknum to change date to week number.
data
Are there any better formula or any ways to make this file faster? Every kinds of suggestions are welcome!
I was thinking about using Pivot Table, but I don't know how to make pivot table from this kind of datasource.
PS. VBA is the last option.
You can download example file here: https://www.mediafire.com/?t21s8ngn9mlme2d
I will post this answer with the disclaimer that it is entirely dependent on the size of the data set. That turning on and off the auto calculate is the best way, but your question doesn't let me do that, so keep reading.
Your question made me curious, so I gave it a try and timed it. I essentially set up two columns of over 100,000 rand numbers choosing from 1-1000 and then tried to do a countif on the two columns if they were equal. I made a macro that I can run that turns off the autocalculate, inserts the start time, calculates, and then inserts the finish time. I highlighted in yellow the time difference.
First I tried your way, two criteria, countifs:
Then I tried to combine (concatenate) the two columns to see if I could make it easier by only having one countif criteria and data set. It doesn't. see result below:
Finally, realizing what was going on. I decided to make the criteria only match the FIRST value in the number to look for. I was essentially reducing the number of characters to check per cell. This had a positive result. See below:
Therefore my suggestion is to limit the length of the words you are comparing in anyway possible. You are mostly looking at dates, so you might have to get creative, but this seems to be the best way possible without going to manual calculation.
I have worked with Excel sheets of a similar size. Especially if you are using the data on a regular basis, I would heartily recommend switching to a proper database SQL based, Access, or whatever fits your purpose. I does wonders for the speed and also you won't run into the size limits of Excel. :-)
You can import the data you have now fairly easy.
I am happy as a clam with my postgresql db.

Any solution to the Today Calculated Column problem is SharePoint?

I would like to be able to use today's date in a calculated column in a SharePoint list to, for example, determine whether a task is overdue. There is a well-documented trick that involves creating a dummy column named "Today," using it in a formula, and then deleting it, thereby "tricking" SharePoint into using the Today function.
The problem is that this method does not work reliably -- the calculation is not dynamic; it is only made when the item is saved, and therefore the Today "column" effectively becomes the Modified Date. (This is probably why SharePoint won't let you use the Today function in a straight-forward way.)
Has anyone found a solution that works? I know I can use javascript to get the actual date on the client side and display colors, flags, whatever, but I am looking for a "server side" solution.
For reference, the Today column trick and its problems are described fairly well at these two posts and associated comments:
http://blogs.msdn.com/cjohnson/archive/2006/03/16/552314.aspx and http://pathtosharepoint.wordpress.com/2008/08/14/calculated-columns-the-useless-today-trick/
There simply isn't a work around for this. As the values for the list are stored in the database and returned "as is" to other featurs such as the search crawler, a dynamic field cannot be created.
It is possible to create a custom field that will display the value using todays date in its calculation.
In addition to Christophe's (PathToSharePoint)'s article this also covers the Today trick and why it doesn't work
The Truth about using Today in calculated columns
There are a number of fudges, probably the best one is Dessie's console app (mentioned above by MNM)
Dynamically updating a SharePoint calculated column containing a Today reference
Its good but its not perfect, for example you may have to worry about different timezones.
Before going down this route you should ask yourself if you really, really need to do this. For example :-
If you want a countdown (days overdue/days left to complete a task) then you can use SPD and a XLST Data View web part
If you want a view to show overdue items or items created in the last X days ec then you can use [Today] in a views filter 2
If you create a Today column it needs to be updated. You can do that with either a timer job or by placing a jquery script on a page that is hit by the user. The script could call SPServices.SPUpdateMultipleListItems to do the update. Pass a CAML clause so that you only update the list items where the Today value needs to be updated, e.g. once per day.
My advice is to create your on field that does this calculation for you and then reference it in your SharePoint list. Not a simple implementation but it would work.
I have been looking for a solution either, still no luck.. The Today column trick has the limitation of not being dynamic.
I do have one suggestion though, why don't we create a timer job that will update a certain a certain column with the current date every day at 12 AM. I know some of you all might think it an over head. Just my suggestion :D!!
I came up with a very rough, but working solution to this problem without having to do any coding. I'll explain both how i made the today column and how i worked that in to an overdue column, becuase that column was a pain to find out how to do as well.
First, I made a column named "today" (gasp!). Next I made a column named "Days Overdue". I then opened up sharepoint designer and created a new workflow. I set it to run every time an item is edited/updated (keep in mind I turned off versioning for this list, otherwise I would have had to resort to coding to avoid a bunch of useless data building up on our server). I set the actions to simply store the modified date in a workflow variable, then change the value of the today column to that variable. although the modified column is a date/time and my today column is just a date, it transfers just fine. I then set the workflow to pause for 2 hours. you can set this to whatever amount of time you want obviously, it will just change the latest possible time for your today column to update, i.e. 2AM in my case.
on to the days overdue column. this is the code for that guy -
=IF([Due Date]>Today,"None",IF([Date Closed]=0,Today-[Due Date],IF([Due Date]>[Date Closed],"None",IF(Today>=[Date Closed],[Date Closed]-[Due Date],IF([Due Date]<Today,Today-[Due Date])))))
This shows the days overdue in number form in days, or if its not overdue, it shows "None". You can use either a number format or a string format, but NOT A DATE FORMAT. Well, I hope this helps anyone who is running into this problem and doesn't want to have to delve into coding.
EDIT: I forgot to say that in the code above for the days overdue column, I put in that if today is past the date closed, to use the date closed minus the due date instead of today minus due date, to ensure that the calculation doesnt keep occurring after an item has been closed. you probably would have noticed that in the code, but i felt i should point it out just in case.
EDIT 2: The code I had in before my 2nd edit for my calculated column didn't calculate the days overdue properly after an issue had been marked "closed." I put in the updated code. The last part of the code doesn't make sense, as it is the same logic as the beginning, but it worked so I didn't want to take any chances! :)
Peace.
I've used the following and had no problems.
Field Name: Overdue
Field Type: Calculated
Data Type Returned: Yes/No
Formula:
=AND([Due Date]<NOW(),Status<>"Completed",[Due Date]<>"")
Here is a workaround:
Create a date column called Today.
Use this column in your calculated formula (ignore the fact that the formula returns a wrong value).
After you are done with the formula, delete the Today column from your list.
For some reason it works this way! Now Sharepoint treats the Today in your formula as today's date.
Note: If you decide you want to change the formula, you have to create the Today column again. Otherwise, it wouldn't recognize Today as a valid column.
I Tried #Farzad's approach and it seems to be working perfectly. I wanted to do a custom count on Days Elapsed so added a calculated column which previously I was using a difference between the Created Date and Modified Date Columns, which was only showing up whenever a user updated the post, much to my dismay.
I now have a formula which works as I would want to and uses the Today column, and here it is for anyone who would like to use it. I also have a Status column on the basis of which a base of On Hold is used, and the remaining formula are based on the date difference of Today - Created.
=IF(Status="On Hold","On Hold",IF(AND(Today=Created,(DATEDIF(Created,Today,"D")=0)),"New",IF(AND(Today<>Created,(DATEDIF(Created,Today,"D")=0)),"New (updated)",IF(DATEDIF(Created,Today,"d")>3,"Need Update Immediately",IF(DATEDIF(Created,Today,"d")=1,"One day old",IF(DATEDIF(Created,Today,"d")=2,"Two days old",""))))))
Basically its just a bunch of nested IF conditions which get me labels on the basis of which I can add a group to my view and filter out data if needed. Hope this helps anyone looking for an answer!

Resources