Excel - How to Manualy calculate a worksheet every second? - excel

My sheet contains links from a third application and it's set to Automatic calculation.
New data retrieved every few seconds so I should get the data every second or close to it (One of the fields the sheet retrieved is "time" so I can know how updated is that data).
Yet, I found that the data is updated every 3 minutes (and more..) rather than every second or few seconds.
I changed the Automatic calculation to Manual calculation, Results: Every click on the Calculate Now results with a "new updated" data which is indeed updated from a few seconds ago rather than 3 minutes, like it should be in the first place.
I suppose that the Automatic calculation has an algorithm to decide when to calculate and that algorithm doesn't go into my favor,
So how can I set the sheet calculation to be immediate or at least to be every second or so?

Related

Power Query - Best way to count data from another workbook and store the value after the data is updated?

I have a workbook containing several thousand records. Each day the raw data is refreshed by downloading a master file from a central system and saving over the existing file. I need to create something that will count the number of records that match a certain criteria (i.e. how many belong to my department) and store the number in a table each day, i.e. Monday X, Tuesday Y, Wednesday Z etc.
Many years ago a colleague developed a macro to do this by opening the source file and copying the source data into a new file, but it is also programmed to produce several other MI reports within the same macro that are no longer needed, the VBA code is extremely long and complex and the whole process takes around 2 hours each day.
I'm fairly new to Power Query, but I know I can import the data in seconds and use a simple Countif to tell me what I need to know, but obviously once the data refreshes the following day the value from the Countif will update too. Instead, I need to store the values of the previous days and weeks to retain the count in one cell and the newly refreshed value in another. It also needs to be something very simple that a complete beginner could update at the click of a button to automate the process.
Can anyone suggest the best way to do this? Thank you in advance

How to update parameter value from excel file on each simulation day in Anylogic

I am working on a model in which I have a parameter called supply. This parameter should change on a daily basis as I have a different supply amount of raw materials each day. I am using an excel file containing a column called supply and 10 rows (supply values for 10 days).
My question is how can I use this excel file as input and have the model read the first row on day one, 2nd row on day 2, etc? Updating the parameter on each simulation day.
I am using the Anylogic personal learning edition.
Loop across all dbase entries at the start of the model (using the database query wizard, choose option "iterate over returned rows and do something").
for each row, compute the duration from model start to what the row represents
for each row, create a Dynamic Event (on Main or wherever) using create_MyDynamicEvent(x, HOUR) where x is the duration from point 2 above, in hrs. Give it an argument quantity and provide the current row's value
in the Dynamic Event, you change your parameter with the value provided, i.e. set_myParam(value)
You can also use a schedule or a source to do this, but the approach would be quite different.

Calculate minutes in specific period

I have a spreadsheet which has employee working times, listed as Sat-In and Sat-Out for a specific date. The employee shift spans several ours and each "In-Out" period is recorded as a separate line which means the time between the Sat-Out and the next Sat-In means the employee is on a break. I also calculate the time, in minutes of each "sitting" period.
What I can't seem to figure out is how to add a formula which takes the data and further refines it in this manner:
1. I have a core period of 1030-1530, as an example, which is the busy time and requires the maximum employee coverage. The shifts of employees generally spans this core, but in some cases their shift may start or end in the core.
2. I want to calculate how many minutes the employee worked within the core only. I can obviously do this manually using the data, but a formula would be preferred, if possible.
3. As an example, if a person sat-in at 1445 and sat-out at 1545, the core time calculation would be 45 minutes (1445-1530).
I've attached a snapshot of the data to help my explanation.
FYI - the information is pulled from a database as JSON data and converted to excel. I'm not very familiar with JavaScript, but if someone knows a way to do it programatically, I'm willing to give it a try and learn.
Thanks!
![excel]: https://photos.app.goo.gl/dRSTE72CXNa18RzP8
In below example I've used: =MAX(0,MIN($O$2,H2)-MAX($O$1,G2)), and formatted like [mm].
In Excel, units are days, so if you want to calculate the amount of minutes between two timestamps, you need to subtract both and multiply the differencee by 24*60 (being the amount of minutes in one day).
E.g. You start working at 09:07 (cell B2), and finish at 18:07 (cell B3), having a 45-minutes break. Then the time you worked in minutes, is:
=(B3-B2)*24*60-45
Make sure the cell formatting is correct (general), you'll get : 495.

Superimposing time data in excel

So I want to make a load duration curve in excel. And I have the demand and the time for which the EV is active for a year. So basically I want to make a load curve for the whole year. My problem is that I only have like a starting and end time where the EV is active during the day and data does not show that it is zero elsewhere.
So I want to create a whole sheet with 24 hour times for 365 days using the data that I have.
My confusion is how to take the limited data that i have which starts at any time not on the hour to make a full 24 hr one year data for a load duration curve.
In a chart with 365 days on the X axis, the distinction between different times of the day will be difficult to discern.
If you use a line chart you can set it to show empty cells as zero instead of connecting empty cells with a line.
If you want the line to drop to zero, you must have rows for that date with no data in the values column.

How do I sum time differences between "SET" and "RESET" events?

I want to go through my logs and find out how long each output has been on during a specific time period. Pseudo coding it I would find the oldest SET then look for the next RESET entry calculate the duration between the two timestamps and add that time quantity in minutes or decimal hours to a sum then find the next SET and Reset and add that to the sum as well. There will likely be times when there is a RESET event but the SET event is outside my search window and I can ignore those. There will be many different outputs and I want the sum for each distinct "system" and "code" in the code column as the code contains unit information and the other columns are ancillary.
Example
Time window from 11/15/2015 03:00 to 11/18/2015 03:00
Spreadsheet looks like this:
System,Time Stamp,Code,Unit,Event Text,Set/Reset,
1,11/17/2015 21:41,ABCD,A,Temp is too high,RESET,
1,11/17/2015 21:39,ABCF,B,Movement is too slow,SET,
1,11/17/2015 21:41,DCTY,A,Air flow rate is unstable,SET,
1,11/17/2015 21:44,DCTY,A,Air flow rate is unstable,RESET,
1,11/17/2015 21:43,ABCF,B,Movement is too slow,RESET,
1,11/17/2015 21:43,CATG,C,Door ajar,SET,
When manually crunching the numbers I know Unit B had 4 minutes of code ABCF and unit B had 3 minutes of DCTY. Unit C's CATG has 1 day 13 hours and 45 minutes of set time since it has not yet reset before the end of the window. Also there will most of the time be gaps between the reset and the next set event, so there are two modes: time from set to next reset and reset to next set. I only care about the set to reset duration sums as each set to reset sequence may repeat multiple times. My purpose in seeking these durations is right now I have only been using set event frequency to track issues but an event that is not cleared is not highlighted that way.
Bonus: Can this be done without VBA scripting?
This is a solution that addresses the majority of your requirements. In column G starting in G2 you would place the following Array Formula:
=IF(F2="SET",SUM(IF($C:$C=C2,1,0)*IF($F:$F="RESET",1,0)*IF(ISNUMBER($B:$B),$B:$B,0))-B2,"")
This is inputted using CTRL + SHIFT + ENTER. Then copied down to all your rows.
Basically it extracts into an array values of 1 for rows that correspond to the same Code and are "RESET" but only for rows that are "SET". It then multiplies these 2 arrays (not matrix multiplication FYI) by the column with the Time Stamps effectively extracting only Time Stamp that confirm to both conditions. Note that as the formula then sums the array this will only be effective if there is only 1 set of SET/RESET for that code. You can add another condition based on the Unit much the same way.
Not a full solution but I hope a starting point.

Resources