Google Sheets - Protect monthly range script needs monthly triggers at specified date and time - date

I would like to request help with a script Im trying to put together.
Linked is my test spreadsheet including the script I currently have on the second sheet.
The idea is that this sheet will be copied individually to a group of people. Each person will get their own sheet, editable only by them and myself. It does not get shared any further. Each day the person will add a value into the corresponding day's cell.
On the last day of each month at 8pm, I would like to protect (lock) the cells for that month, to stop the person changing any values that they previously entered.
I have put a repeating script together with a function for each month, covering each range. The problem I'm having is creating triggers that will run the function on the required day. If I set a monthly trigger, they will all trigger at the same time at the end of the first month. Ideally I need individual triggers that will run once a year on the specified date and time for each individual function.
Is this possible? Is there a better way of doing this?
I also realise that I will need to give permissions for each function run, and possibly for each individual copy of the sheet I give to said persons. Is there a clever way around that?
Im also thinking another approach would be for the script to trigger each monthly function 'on open' if the relative date has passed. For example, on Open, if Date is Feb 1st, lock January range, and so on.
Any help provided would be greatly appreciated.
(Note: the true sheet I copied my script and layout from starts this section at Column U, which is why I have minimised Columns A-T).
Test Sheet Link: https://docs.google.com/spreadsheets/d/13z8eWpo6oislkGX3USifLWqh5sz3DsJpSY1YyqNLrx8/edit?usp=sharing

Related

Counting days between 2 dates and swapping one of the dates for another if cell if not empty - google sheets

As the title suggests I'm wondering if there is a way to count days from 1 Column from the current day, then when filling in another column it stops counting the difference in days?
I'm using the following formula (found online)
={"Days";ArrayFormula(if(A3:A="",,int(B3:I)-left(A3:A,10)))}
Column A being where my date of entry is, column B is a hidden column with every row set to the
=Today()
I have another column, Column C that I will enter the date manually after date of completion, at which point I would like it to then stop counting the days and show me the number of days between Column A and C (Date 1 and Date 2)
I'm not overly experienced in google sheets but I'm thinking maybe there's a way to
check if column C is empty, if so carry on with todays date, if it's not empty to
calculate Column C - Column A?
Would making an new column for checking if the completion date has been entered work?
ISBLANK(C:C)
If so would it be possible to get one formula to check whether True or False and determine what 2 dates to work with? Lets say Column D is for ISBLANK the following is what I think of
={"Days";ArrayFormula(if(CD:D="False",,int(C3:C)-left(A3:A,10)))}
={"Days";ArrayFormula(if(D3:D="True",,int(B3:B)-left(A3:A,10)))}
When I try this I have no luck and get a "Result was not expanded automatically, please insert more rows (1)" error message
Any help would be appreciated!
Apply the formula :
=if(B2="",today(),B2)-A2
at C2. And drag downwards. That's should do.
Please share if it work/understandable/not.
Sorry it's a bit hard to understand this question, if you could post a current and desired screenshot example that would help I think.
So, I think your best bet here is to review this video if you're wanting sheets to auto-input a time entry when a cell is modified:
https://www.youtube.com/watch?v=548dD3iXetg
And it will show you how to script a cell to enter in a time entry when another cell is edited, and then you could use a variation of formulas to calculate the difference between the days of the original minus the date from the script (such as the once referenced below or by #p.phidot )
So for an example, once you script the time entry to work in the background of the sheet, you have a formula using an IF statement to make it pull between your today date or the new date being entered.
My cell references below are an example as I can't follow the question sheet.
=if(b2="",A2-B2,A2-C2)
This way if b2 is not blank it'll do a2-c2. You could also use ISBLANK if you like.

Tableau comparison calculation between integer dates

I'm currently struggling with a calculation I'm trying to create in Tableau so any help you can provide would be great.
Basically I have a calculated field within Tableau called [ExampleCount] which is a count distinct based on a simple Yes/No condition.
I have this information displayed on two separate sheets in a dashboard, one filtered for the current activity month and one for the previous.
What I now need to do is have another sheet with the same calculation of [ExampleCount] but showing the difference between the current/previous months.
So: [ExampleCount (This Activity Month)] - [ExampleCount (Previous Activity Month)]
The Activity month is an integer value, currently ranging from 1 - 9.
I feel like this should be a simple calculation but I've tried several different methods and have been unable to come up with anything conclusive.
It would also be good if this could change periodically.
Kind Regards,
Plain_Lazy

Create a warning prompt box that appears before parameters are set in Crystal Reports

I have created a Crystal Report for some of my users with a date range parameter set. The volume of information that the SQL command returns means that anything over a 7 day period in the date parameter slows the report to unusable speeds and subsequently locks the DB for all other users.
Does anyone know of a way to create a prompt in Crystal Reports that will appear before the parameter set? I.e. As soon as they select the report and click "Open", the first thing they see is a box saying "Please ensure a maximum 7 day date period". Then upon clicking "OK" or something of my choosing, they are presented with the parameter fields and can continue with the report.
If this cannot be done, is there a way to restrict the parameters so that when the users select the start date, they can only select a maximum of 7 days after.
The other option, if it is doable, is to have them select the start date and then it auto complete the end date with a date 7 days after the start date.
At the moment i have just added (Must be a 7 day period) to the parameter title but i dont feel this does a good enough job at advertising it and as soon as i publish it i know someone will want to get 4/5 years worth of data...our clinicians will be most unimpressed if they PAS system locks up during a busy clinic.
I have attached a screenshot of the kind of thing i am after. It is a little crude as it was done in paint but it gets the point across.
I have searched high and low for this solution so i am not sure it even exists, but am asking out of sheer desperation.
Thanks in advance,
Mike
If you use Crystal Report solely (not within a program like .Net app) you can select your latest proposition. Get start date and in your SQL command (View, Stored Procedure, ...) select items from startDate to startDate + 7 days.
Depending on your DBMS there are ways to add some value to date (like dateadd function in MSSQL).
So its done.

SUMIFS with multiple criteria, one of which is a single day

I'm trying to get a formula that will break down the amount of times a user enters a contest each day.
I'm pretty new to this whole thing, basically putting it together using google to figure out the code I need to use/modify. Explaining why something works would be greatly appreciated so I can use it elsewhere!
Here's a dummy of the form I'm banging my head against.
I would like the form to be reusable, so on the Sorted form I have a date key that automatically fills out the week when you choose the first day. Because of this, I would like each formula to refer to this date key, instead of manually typing the google equivalent of 'February 1st, 2015' into the formula.
I've tried to use the SUMIFS formula, and I've run in to a few errors.
Apparently both pages have to be the same amount of rows, otherwise I get an 'Array arguments to SUMIFS are of different size'. I didn't want my 'sorted' sheet to be 1761 rows long, since all of the duplicate names will have been condensed and I wanted it prettier. Nuts to that! Guess I can hide the rows? Is there any other solution?
It looks like this works:
=SUMIFS(Entered!E3:E1000, Sorted!E3:E1000, Sorted!$E3, Entered!A3:A1000, date(Sorted!$C7))
Where entered!E: is the number of entries, sortedE: is the list of usernames, and E3 is the specific one I'm looking for. Then EnteredA3 is the list of dates and time, and Sorted!C7 is the specific date I'm looking for. I don't get any results!
If I click on my C7 and sorted!A, the little calender pops up, which means they are dates (I think?). One includes the hours:minutes:seconds and the other doesn't, which I think is my problem. I would like to have sorted!C7 be the entire day, and filter out all of those entries.
This is taking information entered via a google form which I won't have control of, so I can't really change the H:M:S additions to the date column.
Thinking ahead to day 2 and onwards, will the same formula work when sorted!C10 is C$7$+1? Is it not a date anymore?
I would also like to add up the amount of daily entries, in sorted!S7 and below. I've tried wrapping both the column of dates and the date from my day key in the date() thing, but it doesn't seem to work either.
=SUMIF(date(Entered!A3:A),date(Sorted!C7),Entered!E3:E)
It gives me a '1', and I have no idea where that comes from.
I haven't been able to find much about the google SUMIFS function, mostly how to replicate it from before it was a thing.
And for even MORE complexity:
I was wondering if it is possible to have UNIQUE find the IDs in entered!C, and return all the associated usernames. That pesky angelo changed their username to 'pants' midway through the contest, and I'd like to be able to see both names and add up both 'angelo' and 'pants' entries in the same line in my formulas.
I feel like I'll need a few hidden columns that have the UNIQUE ID number and the associated usernames that I pull into my Sorted!Username column, but I don't know how to search the IDs to find the different usernames.
I tried to google that, but I have no idea what I'm googling.
Whewph! That is a lot of questions, thanks for any help!
Too long for my taste, but you might try:
=sumifs(Entered!E:E,Entered!A:A,">="&$C$7,Entered!A:A,"<"&$C$7+1,Entered!B:B,$E3)
in Sorted!F3 and copied down to suit.
Oh my goodness, you are a hero!
My final code wound up being:
=IF(ISBLANK(Sorted!$E3)=TRUE, "", sumifs('Entered'!$E:$E,'Entered'!$A:$A,">="&$C$7,'Entered'!$A:$A,"<"&$C$7+1,'Entered'!$B:$B,$E3))
I changed the start and end points by making $C$7 into $C$7+1, and the ending one into +2. (In case anyone else is looking at this answer.)
I'm super pleased that it worked!
Using this I managed to add up each of the daily entries, just by adding up the columns they were in.
I gave up on the UNIQUE idea, if someone changes their username during the contest, then they can add up the two rows themselves.
Thanks again! I'd upvote you, but I can't yet.

Excel - Insert "day" on a cell and format it to date with current month and year

I am working on a home accounting template (and could not find any good one :-/), so I am creating one for each month. Both in my expenses and my incomes, I would like to have a date column where I just have to insert the "day" (e.g.: 22) and it automatically fills the rest with the current month and year (or I could set them in another cell).
For example: 22 + ENTER would return: 22/12/2014
If I do this, I automatically get a default date: 22/01/1900
I do not know if it is possible to change this defaul date depending on the current one or any other value.
I have tried with a different strategy: if the amount column is not empty, fill in with today's date: =IF(A3="";"";TODAY())
The problem is that I do not always register today's expenses, so I need to change it manually. I was just wondering if this is possible and there is a better way (maybe a macro?).
You need Excel to modify the cell contents after you press ENTER. The only option seems to be a Macro using the Worksheet_Change event.
Please check out this other question. I think that will help.
This can be achieved with simple formatting and use of controls that are available in Excel. VBA will give you drastically more flexibility, however the request above can be accomplished without learning VBA.
I have included a sample file here.
Steps to recreate:
Create a range of months. I created a range including the current month through 12/2014
Insert a combo box from the developer tab. Right click and select Format Control. On the Control tab, input the range you just created and then select a "linked cell". This will insert an integer to indicate which item you picked in the list, starting at 1.
Use the attached formula to add the DAY that you enter in the first column and VLOOKUP the month and year from the value chosen in the combo box.
Enhancements: I used conditional formatting to change the text color of the days you enter to WHITE. This way you won't see them. I also included some checking in the VLOOKUP formula: the day you enter must be a number and must be non-blank for a date to populate.