I have a database of users (with a number assignment) and an Excel listing of items that I am successfully pulling into two arrays. One array of users, the other of items from Excel (tasks). I am trying to think of the logic to represent this scenario:
A user in the DB can exist with a number 0-5. Basically this represents how many days off they are in the week, and help break up how many items in the Excel range each person can get so as to proportion correctly items (before I was using a Boolean indicator to indicate to either include or exclude). For example:
User | Present #
-------------------
Jared | 0 'present daily
John | 0 'present daily
Mary | 1 'off 1 day
Tom | 5 'off rotation entirely
Question is: what is the best way to relate this to how many items they should be getting overall?
I would expect Jared and John to get the most, Mary a bit less, and Tom would never be included. Let's say I have 50 items.
One way I have thought is, while looping the names into Excel, count each time I start back at the top of the array as a "pass" (while assigning into Excel cells).
Anyone with a 0 is never skipped through each pass
Anyone with a 1 is skipped every 4th pass
Anyone with a 2 is skipped every 3rd pass
Anyone with a 3 is skipped every 2nd pass
Anyone with a 4 is skipped every other pass
Anyone with a 5 is never included (easy)
For my example, Jared and John would always be used, Mary would be skipped every fourth pass, and Tom would never be used.
Does this make sense?
What is the best way to catch looping through an array every Nth time?
Am I going about this in the correct manner?
To avoid a lot of looping and the delays this might cause, I’d suggest calculating a ‘demand factor’.
There are 50 items (in the example) to be distributed according to availabilities. The availabilities are shown as 0 present daily to 5 off rotation entirely, but it is easier to work with these the other way around: ‘off rotation’ has no resources available so 0 and ‘presently daily’ has all weekdays (?) available, so 5.
The User | Present # table would then become:
Jared 5
John 5
Mary 4
Tom 0
14
So 14 person-days are available to cover 50 items, an average of 3.57 items per person-day. Presuming an item can’t be split that is 3 items per person-day and 8 over. The ‘3 each’ can be allocated in one pass by multiplying the (revised) table values by INT(item_total/table-total). So for Jared and John the result is 5x3 = 15 and for Mary 4x3 = 12.
That though only accounts for 42, so 8 have yet to be allocated. 3,3,2 ‘extras’ is obvious (resulting in 18,18,14) but programming that not so easy. I’d suggest where there is any residual from the INT formula then use its result +1 (ie here 4 rather than 3) accept preliminary results of 20,20,16,0 (6 too many) then loop through each user knocking 1 off (where possible) until 6 have been knocked off.
This doesn't entirely make sense since you appear to be assigning weekly tasks, one per day:
Anyone with a 0 is never skipped through each pass
Anyone with a 1 is skipped every 4th pass
Anyone with a 2 is skipped every 3rd pass
Anyone with a 3 is skipped every 2nd pass
Anyone with a 4 is skipped every other pass
Anyone with a 5 is never included (easy)
However, presuming the above, you skip users when their individual TaskAssignmentsAttempted Mod (6 - Present#) = 0.
Perhaps you need:
Anyone with a 0 is never skipped
Anyone with a 1 is skipped once every 5 passes
Anyone with a 2 is skipped twice every 5 passes
Anyone with a 3 is skipped 3 times every 5 passes
Anyone with a 4 is skipped 4 times every 5 passes
Anyone with a 5 is always skipped.
Presuming the above, you skip users when their individual 5 - Present# is less than their individual TaskAssignmentsAttempted Mod 5.
With either of these, you need to track the number of times that each user has an assignment attempt (successful or not), as well as the actual assignments.
Related
Coming from a ELK background, Kibana had some nice functionality where you could view surrounding events of any record you wished https://www.elastic.co/guide/en/kibana/current/discover-document-context.html, i.e. view the 5 preceding and 5 proceeding events.
Does something like this exist in the Kusto Query Language?
Edit: I should also mention the requirement for this as I realise it might exist, but within a different form.
I'm looking to find several events that need to have all occurred during a specific time period, i.e. the previous 5 minutes.
Example; if EventID's 1, 2 and 3 show, I'm not interested. However, if 1, 2, 3 and 4 show (within X minutes of each other) then I would like my query to pick this up.
Any hints or tips are appreciated.
It seems that Time Window Join is what I needed - https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/join-timewindow
suppose there're 3 items with their respective vol:
a b c
12 20 28
each has a certain vol added and subtracted
a b c
added 3 5 12
subtracted 2 7 8
What format can best visualize the dynamics of inflow and outflow as such, even if number of items are far more than 3?
As I commented above, one visualization you could use would actually be a combination of a line chart, to show the running overall trend of the volume, along with a bar for each day, to show the positive or negative gain for that day. In the financial world, there is already such a chart, called a candlestick chart. Here is sample of one:
The way to read the chart is that the circle is where the trend ended in that year. But the start of the bar (below for losses, above for gains) is where the value actually started in that year. This is a convenient way to convey both pieces of information which you want to get across to your audience.
I have a program that reports how many times a customer has visited between a certain our of the day. In this case, the program runs each day, to find out how many customers came in between the hours of 6 and 7. The problem I'm running into is I also need to keep a running tally of the number of customers visted between the hours. So I need the output to look like:
Today: 5
Total: 5
Today: 5
Total: 10
Today 5
Total 15
I can store the info in an XML file, but I have 16 different locations I'm tracking so that's a lot of writing, and reading from an xml file, so I assume there is a better way to handle this? I basically need the program to load the value of the "total" which is Today, plus previous days.
I fill the values like this:
firsthour = ds.Tables(0).Rows(i).Item(x)
secondhour = ds2.Tables(0).Rows(i).Item(x)
Percentage = Math.Round(ds2.Tables(0).Rows(i).Item(x) / ds.Tables(0).Rows(i).Item(x) * 100, 2)
firsthourtotal = ds.tables(0).Rows(i).item(x)
secondhourtotal = ds2.tables(0).Rows(i).item(x)
Obviously, I need the Fisthourtotal, secondhourtotal, to be stored for each of the 16 results in the array, to be accessed each day when the program runs.
Probably not the best way but....
If I was doing it I would use My.Settings and use the System.Collections.Specialized.StringCollection type for the situation described.
Nice and easy to read and write to, just remember to My.Settings.Save after writing to it otherwise it will wait till you close the application before updating the record!
This is probably a fork in the road question. I have a journal blog that date stamps a continuation of a single field within a record.
Example:
Proj #1 (ID): Notes (memo field:) 10/12/2012 - visited site. 10/11/2012 - updated information. 10/11/2012 - call client. 10/10/2012 - Input information.
Proj #2 (ID): Notes (memo field:) 10/10/12 - visited site. 10/10/2012 - call client. 10/9/2012 - Input information. 10/1/2012 - Started project. etc etc...
I need to count how many updates where made over a specific time frame. I know I can create a hidden field and add + 1 everytime there is an update which is useful for an OVERALL update count... but how can i keep track of number of updates over the last 5 days. Like the example above you may update it twice in one day and I may not care about updates made 2 weeks ago.
I think I need to create an SQL that counts the number of "dates" since 10/10/12 or since 10/2/12 etc.
I have done the SQL: SELECT memo FROM Projects WHERE memo IN ('%10/10/12%', '%10/9/2012%' etc)
and then the Len(memoStringCombined) - Len(Replace(searchword""etc)/Len(searchword) and it works fine for countings a single date... but if I have count multiple dates over 30 days it gets to be quite cumbersome to keep rewriting each search word. Is there a regex or obj that can loop through this for me?
Otherwise any other suggestions for counting updates between time frames would be greatly appreciated.
BTW - I can't really justify creating a new table dedicated to tracking updates because there will be 100's of updates for close to 10,000 records which means the update tracking table will be more monstrous than the data... or am I wrong with that idea too?
I'd like to store data from actual graphs. in other words we might the following for example:
paper: smith
finance type: outgoings
time | 0 10 20 30 ... etc
amount | 10 22 31 44 ... etc
I would like to store the variables paper, finance type and for each the graph data given by time-amount. there will be other variables also (note the above example is fictional)
I'm not here to get solutions although I hardly know anything about databases. Would like to get started. When I type in Google 'store data from graph in database' all I get is information about sql graph types, node etc. I need just some direction for the actual tools to use (MySql or another database type? XML?). I will eventually want to extract the graph data of person and use that information. Google is not being my friend at the moment and I don't know who to ask personally
The database wouldn't be that big but will eventually run into 1000s of entries.
It is possible to model this in a database, but if you hardly know anything about them, you should start learning a bit about ER schema's, normalization (just up to third normal form) and the basic DDL and DML queries.
Anyway, possible model with two tables:
TABLE 'graphs'
- ID
- paper
- finance type
TABLE 'graphdata'
- ID
- GRAPH_REF
- TIME
- AMOUNT
In your table graphs, you put 1 line for each graph you have. You might have a graph for 'smith, outgoings', one for 'smith, incomings', one for "deloitte, reports"... that would be three lines. The ID is just a counter.
In the table 'graphdata', you put 1 line for each data point. Again, the ID is just a counter. The GRAPH_REF is the ID of the graph in the 'graphs' table where this data-point belongs to.
So for your example, you'd have the following graphdata rows:
1 - 1 - 0 - 10
2 - 1 - 10 - 22
3 - 1 - 20 - 31
4 - 1 - 30 - 44
Are you following so far? Now you can make a webpage (or an application, anything you can program that can work with SQL - even Excel or Access will work) that gives a user the choice to create a new graph, or select an existing graph.
Creating a new graph would insert a new row in the 'graphs' table. Then, for each data point, you put a new row in the 'graphdata' table.
When they select an existing graph, you fetch the data points from the graph, and display to them. Maybe they can add/delete points?