I know this is a tough one but I'm basically trying to say. Give me a service call and its completion date, then give me the Max date for all service calls where the date is less than the date of the service call I'm inquiring about.
Basically the end result I'm looking for is to say was there another service call on this piece of equipment that was within the last 30 days.
So as you can see in the image for say Asset 50698 service call 579032 we have a date of 11/9/2020 the call below that was 10/22/2020 which was less than 30 days. I want to somehow find a way to count how many service calls I have where this has occurred. Is this possible?
I think you're looking for a context operator In, ForEach or ForAll (in in this case)
Add a variable "MaxAssetDate" and assign it a Formula similar to the following based on your column headers.
=Max([Service Call Completion Date] In ([Asset ID];[Service Call])) In (Asset ID])
Then add this as a column. Provided you have a prompt filtering for a given asset or "date" this column will then show the max date for each service call of the same asset ID. Then add a new variable: ServiceCallDaysDiff: Then by using DatesBetween() with "MaxAssetDate" and ServiceCallCompletionDate and DayPeriod; =DatesBetween([ServiceCallCompletionDate];[MaxAssetDate];DayPeriod) you should get a number 0-X. Then add a filter based if the number is between 1 and 30 then you show those records, otherwise hide the rest; or do whatever logic is then needed.
Now if you're dealing with hundreds of thousands of records this isn't ideal as you're putting all the processing on the webi engine when it ideally would occur as an object in the database layer. However if you only have a few thousand records this should be managable.
To add a count of service calls...
add variable: ServiceCallsCount:
=Sum(Sum(If([ServiceCallDaysDiff]=0;0;1)) In ([AssetID]))
this will count the non zero day differents. Note this will extend beyond 30 so if you want to limit by 30 days adjust the if statement to zero out those not between 1 and 30.
This is but one approach: there may be simpler ways.
Related
I work at a school and at the end of each semester we need to total up instructional hours for each student in each class, then get the sum for the whole class. We keep our attendance on a Google Sheet each semester, so I can use fancy functions to do this. This function has worked perfectly the last couple years:
=arrayformula(sum(countifs([data range],{"","T","*all *","*no *"})))
I run this at the beginning of a row and it counts all instances where a student (or the entire class) would be counted as present, but doesn't count anything else; just like I need it (students are counted as present if the cell is left blank). I run this function on each row (for each individual student) and then run a quick sum at the bottom of the sheet and it's all good to go.
Well, this worked because our classes were all 1-hour long every day. Starting this semester, they are either 1 hour and 20 minutes or 32 minutes depending on the day of the week (each class has one occurrence that is an hour twenty and one that is thirty-two minutes each week). So the above function no longer works as it just totals how many classes a student showed up for. I now need something that will do that, but also multiply the result of each cell (1 or 0) by either 1.33 or .53 depending on the day of the week. This can be done by referencing each column's header, which has the date attached and running a WEEKDAY parameter nested in an IF parameter like so (using a class that has the longer instance on a Friday for example):
(if((weekday(Z$1))=6, 1.33, 0.53))
I put that together into a function that works:
=countifs(Z2,{"","T","*all *","*no "})(if((weekday(Z$1))=6, 1.33, 0.53))
... but I will have to create a dummy column next to the column that has each date's attendance data, tailor the formula to the column next to it and copy and paste the formula all the way down the column. I should only need to change the formula once per sheet, but I'll still need to create dummy columns next to each date and then run this formula by hand on each column. After all that, then I can sum up each row. It works... but I want something less time-intensive and prone to error.
What I am hoping for is a function that does what I have now (for single cells), but runs each portion of this function on each individual cell across an entire row of data after I add it to the beginning of the row and then, preferably, sums up the total hours at the end (should just be able to add a SUM parameter to the beginning of the function?); all in a one-cell function. I have tried using an array like I had before (in the first formula above), but the problem there (there's probably more than one problem), is that I can't get the function to reference each cell's header and run the IF function, I can only get the array to work on the COUNTIF portion of the function. Maybe this whole thing needs to be a script instead?
I hope what I am asking for makes sense and here is a link to a sample of the data I am using:
https://docs.google.com/spreadsheets/d/12fTE_AMlKtlqc_KToYB5TkvpYwFzON9Q6vvRfnDlr0A/edit?usp=sharing
Thank you for reading and I hope there is a reasonable solution to what I'm asking!
try:
=INDEX(BYROW(B2:N15, LAMBDA(x, SUM(
REGEXMATCH(x, "^$|no .+|all .+|T")*
IF(WEEKDAY(B1:N1)=6, 1.33, 0.53)))))
I have requirement to read the data that is already in the output and join the data to input and write back the data to the same output. This build is scheduled every day.
Input:
ID
Refresh_Date
1
6/8/2022
2
6/8/2022
3
6/8/2022
Historical(Output):
ID
Order Date
Order Closure
Age
1
6/6/2022
6/7/2022
1
2
6/7/2022
3
6/7/2022
4
6/7/2022
The input data will be refreshed with new orders every day, so I have join the input to the historical data and find the closure date and time it took to close the order.
The result of the join should be saved as Historical again
I tried using incremental computation but the output in read mode is always giving me empty dataset.
Your intuition to use #incremental decorator is correct.
It sounds like your problem is related to the mode in which you are accessing the current dataframe. Check out the documentation on incremental modes of inputs and outputs; in particular, the default mode is added while you'd probably want to use current or previous for your implementation, as these are the modes that give you access to the data currently within the dataset.
Also, the documentation on incremental decorator is overall very helpful to understand how to make incremental computation work for you. Have a look at different parameters you can pass to your decorator, in particular snapshot_inputs, as it may affect how you access the input dataset as well.
Here's the link to the API: https://ads.indeed.com/jobroll/xmlfeed
You might need to login to see it, but here's the raw text. fromage is one of the options and I'm trying to figure out what it does precisely, to no avail:
st Site type. To show only jobs from job boards use "jobsite". For jobs from direct employer websites use "employer".
jt Job type. Allowed values: "fulltime", "parttime", "contract", "internship", "temporary".
start Start results at this result number, beginning with 0. Default is 0.
limit Maximum number of results returned per query. Default is 10
fromage Number of days back to search.
highlight Setting this value to 1 will bold terms in the snippet that are also present in q. Default is 0.
filter Filter duplicate results. 0 turns off duplicate job filtering. Default is 1.
latlong If latlong=1, returns latitude and longitude information for each job result. Default is 0.
co Search within country specified. Default is us See below for a complete list of supported countries.
Nevermind I figured it out by just tweaking in query in the url. It acts as the "days ago posted". For example, if you need to get jobs that were posted in the last 24 hours, you use 1. If you need it within this week, you use 7. It's useful to keep the query fresh and up to date.
I'm trying to pull some data from a query in my database into a calculated field in a table. I have dates entered for some jobs I'm recording (DateCallOpened, DateQuoteSent, DateQuoteReceived), as well as WorkType for each job to track the type of work done. I've used calculated fields to find the time it took for each record between those dates. I've also used qryTimings to find the average length of time for the WorkType.
I'd like to build fields that showed the ProjectedQuoteSent, and use the data from my query to calculate the date I can expect the quote to be sent, but I just can't figure out how to pull that data out of the query. I was hoping it would be something as simple as:
=[DateCallOpened]+[qryTimings]:[Avg Of TimeToSendQuote]
You can use a DLookup() function to grab your value from your query. So your formula would be something like:
=[DateCallOpened]+DLookup("Avg Of TimeToSendQuote", "qryTimings", _
"[WorkType]=" & [Forms]![frmMyForm]![txtWorkTypeInput])
See this for more info.
So, I have this Report:
And this Query:
The report pulls all of it's data from the query. The fields STA1, STA2, STA3, and STA4 are from the Job Order table in which each job has an order set based on Work Stations (Named CU01, CU02, BR01...).
I have attempted to make macros that essentially say
If Reports![Production Router LBPW]![Work Station 1]="CU01" Then Reports![Production Router LBPW]![Run Time 1]=Query![Query Laser Hours by P/N]![Total Laser Hours]
If I understand properly, a series of statements like that could essentially associate each work station with a specific type of time data (Cutting, Bending, Inserting, and Welding), effectively rearranging my fields to automatically display the time data I want in the places I want them. Alas, I don't know enough about macros to make that work and I know even less about VBA. If I can be filled in on a couple lines of code, or something, that would allow me to accomplish this, I'm sure I may be able to figure it out from there.
One approach would be to create various queries, for example:
QueryCU01
SELECT [Cuttime] As Pos1, [Weldtime] As Pos2, [Rivettime] As Pos3, Bend As Pos4
FROM JobOrder
You report would then refer to Pos1, not CutTime. The labels could also be textboxes, so they update automatically as well, for example:
SELECT [Cuttime] As Pos1, "Cut" As lbl1, [Weldtime] As Pos2, "Weld" As lbl2
[Rivettime] As Pos3, "Rivet" As lbl3, Bend As Pos4 "Bend" As lbl4
FROM JobOrder
It is possible that you could simplify further by normalizing your tables.
Tasks table
Job Action Time Machine SortOrder
1 Cut 10 AB 3
1 Bend 4 CD 1
1 Rivet 30 EF 6
So, what I've done is use a series of Switch functions in my query so that the data that is pulled into each query is inserted into each field by a logical statement. For operation name, the logic is as follows:
OP2: Switch([ST2]="PE01","Insert",[ST2]="PE02","Insert",[ST2]="BR01","Bend",[ST2]="BR02","Bend",[ST2]="WE01","Auto Weld",[ST2]="WE02","MIG Weld",[ST2]="WE03","TIG Weld",True,"N/A")
Which essentially means, If ST2=PE01, Then OP2=Insert, elseif ST2=BR01, then OP2=Bend...
Then I set up another swith that says If OP2=Bend, Time2=BendTime... So on and so forth. This way each field contains a value that is entered based on the logical statements and the order of the jobs is determined by the order that I've set when I enterred the station names in the Job Order Table.