How to add an array formula for updates - google-sheets-formula

I'm working on trying to add an array formula so that the status column updates as information is entered.
This is an order tracking sheet. When an order is entered get set to Available, Once a driver is assigned change the status to Dispatched. As times are entered in the In and Out columns to change from Picked to Delivered. Finally once its checked off as Billed to mark the status as Complete.
So far I've only gotten to
=ARRAYFORMULA(IF(LEN(D3:D&H3:H&I3:I&M3:M&N3:N)=0, "Available", IF(D3:D<>"", "Dispatched")))
I haven't been able to figure out past that.
https://docs.google.com/spreadsheets/d/13tOkLwtPYyWm9rUfkCidqwUygzFfVfmIzV-EwL5i7hM/edit?usp=sharing

I wasn't sure which column was used to mark billed, so I just guess column P, just change it to the proper column. Enter this formula in row 1 of your status column.
={"Status";
ARRAYFORMULA(
IFERROR(
IFS(
P2:P<>"", "Complete",
J2:J<>"", "Delivered",
I2:I<>"", "Picked",
E2:E<>"", "Dispatched"
),
"")
)}
Explanation
Starting inside and working out:
The ranges J2:J, etc, tell the array formula which column to evaluate as it goes row by row, starting at row 2, and ending at the bottom of the sheet.
The IFS formula checks condition:result pairs, If the first condition is met, it displays that value, but if not, it goes to the next one, and so on until it finds a condition that is true or reaches the end.
The IFS formula will return an error if it doesn't find any of the conditions to be true, so the IFERROR says to leave the cell blank if there are no true conditions.
The ARRAYFORMULA evaluates each row for the defined range.
The { xxxx ; xxxxxxx}stacks the items after the semicolon below the item before the semicolon. In this usage, the label "Status" is in row 1, and the results are in the rows below it. This ensures that no one accidentally sorts or erases the formula.

Related

How do I create a column with the time in the previous column + a certain amount of time, only if that time has been entered?

I want to create a spreadsheet where I enter the time on a row and the next column over gives me the time plus 5 minutes. But I don't want it for every row, I only want it if there is some time entered.
This is what I've come up with:
=IF(ISBLANK(B2), "", B2+TIME(0, 5, 0)) //for one cell
=ARRAYFORMULA(IF(ISBLANK(B2:B), "", B2:B+TIME(0, 5, 0))) //attempt at entire column
And this only works somewhat. The first command works perfectly fine for one row, but if I enter it into the array formula, it returns a number between 0-1.
12:16:01 PM 0.5145949074
11:23:49 PM 0.9783448032
1:16:24 AM 0.05652777778
5:16:44 PM 0.7234259259
How do I make it so that the formula works for the entire column, without having to manually do it?
ISBLANK() formula returns false when it detects any content in a cell. Even if there is a formula that generates no output.
You can use:
=ARRAYFORMULA(IF(B2:B="", "", B2:B+TIME(0, 5, 0)))

Sum or Percentage of a word in the results / column

I have a report that in part is providing: Job Date, Job Target Date and Completion date.
I have a column at the end that works out whether or not the job was completed within the target time our outside of returning true or false.
As mentioned, I have created a column to work out whether a job is completed on time and I have tried googling many different solutions and trying them out.
The expression I've used to work out whether the job was completed on time is:
=IIF(Fields!CompletedDate.Value <= Fields!Target.Value, "True", "False")
Now I need an expression to work out the percentage that are within the target. So, let's say there are 80 jobs and 67 are completed in time. It would be 'True' (67) / 80 *100 = 83%.
The expression I've used to work out whether the job was completed on time is:
=IIF(Fields!CompletedDate.Value <= Fields!Target.Value, "True", "False")
Now I need an expression to work out the percentage that are within the target. So, let's say there are 80 jobs and 67 are completed in time. It would be 'True' (67) / 80 *100 = 83%.
I figured this one out myself, again..
If anyone is interested I kept the same IF statement in the original cell. I then created 2 additional cells underneath one containing the text 'Percentage of jobs completed on target' and the other cell I added a new expression that included the original one above;
=SUM(IIF(Fields!CompletedDate.Value <= Fields!Target.Value, 1, 0)) / count(Fields!PropertyCode.Value)
All I had to keep in mind was that I am already showing the results as true and false so in my seconds expression I change the values to numbers so I can calculate. True is '1' so I know that it will not be calculating on 0 as it cannot divide by zero.
So, I did a sum on the number true represented as 1 divided by number of results. Rather than times this by 100 ( 5/19*100 = percentage), I simply left out the times and changed the format of that cell to percentage so it takes the value in the cell and returns the percentage.
Thanks,
Jordan

AddField function does not work as expected

I have the following block of code that iterates through the fields of each table and adds the fields of the current table respectively in order to create a number of tableboxes.
'iterate through every table
For i=1 To arrTCount
'the arrFF array holds the names of the fields of each table
arrFF = Split(arrFields(i), ", ")
arrFFCount = UBound(arrFF)
'create a tablebox
Set TB = ActiveDocument.Sheets("Main").CreateTableBox
'iterate through the fields of the array
For j=0 to (arrFFCount - 1)
'add the field to the tablebox
TB.AddField arrFF(j)
'Msgbox(arrFF(j))
Next
Set tboxprop = TB.GetProperties
tboxprop.Layout.Frame.ObjectId = "TB" + CStr(i)
TB.SetProperties tboxprop
Next
The above code creates the tableboxes, but with one field less every time (the last one is missing). If I change the For loop from For j=0 To (arrFFCount - 1) to For j=0 To (arrFFCount) it creates empty tableboxes and seems to execute forever. Regarding this change, I tested the field names with the Msgbox(arrFF(j)) command and it shows me the correct field names as I want them to be in the tableboxes in the UI of QlikView.
Does anybody have an idea of what seems to be the problem here? Can I do this in a different way?
To clarify the situation here and what I have tested so far, I have 11 tables to make tableboxes of and I have tried with just one of them or some of them. The result I am seeing with the code is on the left and what I am expecting to see is on the right of the following image. Please note that the number of fields vary for each table and the image has just one of them as an example.

Calculations inside a repeater (new repeat) control

A form in a Orbeon form builder contains a repeater control(new repeat).Suppose there are three text controls on each row(or repeat) of a repeater control(new repeat).first two text controls on each row contains numeric values.I want to bring the product of first two text controls to the third text control at run time without any event.there will be multiple numbers of repeat in the runtime ,i.e the row may increase but for each the calculation much reflect at runtime and for each row product of first two must be viewed on the third one
I used the following codes :
if ($quantity castable as xs:double and $price castable as xs:double)
then $quantity * $price
else 'n/a'
Its ok with this xpath expression when there is only one row in the repeater control.But on adding new rows ,i.e on increasing the repeat at run time, all results in the controls of third column changes to the else value ("n/a"). This is working only for a single row of a repeater control(new repeat). Because for every repeat the value must be calculated for each row separately.
Assume this is your node which repeats for each row
<repeater>
<quantity></quantity>
<price></price>
<product></product>
</repeater>
the Xpath expression for calculating the product would be
if(../quantity castable as xs:double and ../price castable as xs:double)
then ../quantity * ../price
else 'N/A'
This expression when used in calculate for the <product> node results the product on each row and there is no event based action required since this is written on the bind definition of the node.
Hope this answers to all your questions

Visual Basic Function Procedure

I need help with the following H.W. problem. I have done everything except the instructions I numbered. Please help!
A furniture manufacturer makes two types of furniture—chairs and sofas.
The cost per chair is $350, the cost per sofa is $925, and the sales tax rate is 5%.
Write a Visual Basic program to create an invoice form for an order.
After the data on the left side of the form are entered, the user can display an invoice in a list box by pressing the Process Order button.
The user can click on the Clear Order Form button to clear all text boxes and the list box, and can click on the Quit button to exit the program.
The invoice number consists of the capitalized first two letters of the customer’s last name, followed by the last four digits of the zip code.
The customer name is input with the last name first, followed by a comma, a space, and the first name. However, the name is displayed in the invoice in the proper order.
The generation of the invoice number and the reordering of the first and last names should be carried out by Function procedures.
Seeing as this is homework and you haven't provided any code to show what effort you have made on your own, I'm not going to provide any specific answers, but hopefully I will try to point you in the right direction.
Your first 2 numbered items look to be variations on the same theme... string manipulation. Assuming you have the customer's address information from the order form, you just need to write 2 separate function to take the parts of the name and address, take the data you need and return the value (which covers your 3rd item).
To get parts of the name and address to generate the invoice number, you need to think about using the Left() and Right() functions.
Something like:
Dim first as String, last as String, word as String
word = "Foo"
first = Left(word, 1)
last = Right(word, 1)
Debug.Print(first) 'prints "F"
Debug.Print(last) 'prints "o"
Once you get the parts you need, then you just need to worry about joining the parts together in the order you want. The concatenation operator for strings is &. So using the above example, it would go something like:
Dim concat as String
concat = first & last
Debug.Print(concat) 'prints "Fo"
Your final item, using a Function procedure to generate the desired values, is very easily google-able (is that even a word). The syntax is very simple, so here's a quick example of a common function that is not built into VB6:
Private Function IsOdd(value as Integer) As Boolean
If (value Mod 2) = 0 Then 'determines of value is an odd or even by checking
' if the value divided by 2 has a remainder or not
' (aka Mod operator)
IsOdd = False ' if remainder is 0, set IsOdd to False
Else
IsOdd = True ' otherwise set IsOdd to True
End If
End Function
Hopefully this gets you going in the right direction.

Resources