## sharepoint online – Calculated Column with multiple If statement

I would like to have a column in which the date is calculated from the values in three other columns.
I have one column named “Last Test Date”, a second column called “Type”, a third column called “Insulation” and the forth column called “Next Test Date.

I need the “Next Last Date” column to be calculated so that it updates automatically when the “Last Test Date” date is changed, and basis the output value on “Type” + “Insulation” + “Last Test Date” values.

e.g.

• if “Last Test Date” equals 1/1/2021 and “Type” equals Winch, then “Next Date Test” equals 1/4/2021.(3 monthly)
• if “Last Test Date” equals 1/1/2021 and “Type” equals Cage, then “Next Date Test” equals 1/6/2021. (6 monthly)
• if “Last Test Date” equals 1/1/2021, “Type” equals Winch, and Insulation<=500 then “Next Date Test” equals 31/1/2021. (monthly)
• if “Last Test Date” equals 1/1/2021, “Type” equals Cage, and Insulation <=500 then “Next Date Test” equals 1/4/2021. (3 monthly)

Any assistance is greatly appreciated.

Posted on Categories Articles

## Evidence of Bank statement

My aunt opened a bank account on my name in England since May 2019 with 3500pounds. Can I use it as my bank statement. Please I need answers.

## google sheets – Is there a way to select a range for a switch statement?

I have a table where one column has numbers from 1 to 25 and another has values corresponding to those numbers.

What I am trying to do is make it so when I change the number in one cell another cell changes to the corresponding number based on the table.

Do I have to do this manually or is there a way to set a range for the cases and values?

Posted on Categories Articles

## turing machines – Explain the simulation of an if else statement in LOOP

I’m learning about LOOP program and in my book I have the following command which is simulated by a LOOP program:

$$text{if} x_i = 0 text{then} text{P1} text{else} text{P2} text{end}$$

This is simulated in LOOP as:
begin{align} &x_n := 1; \ & x_{n+1} := 1; \ &text{loop} x_i text{do} x_n := x_n -1 text{end}; \ &text{loop} x_n text{do} x_{n+1} := x_{n+1} -1 text{end}; \ &text{loop} x_n text{do} text{P1} text{end}; \ &text{loop} x_{n+1} text{do} text{P2} text{end}; \ &x_n := 0; \ & x_{n+1} := 0; \ end{align}

There is no commentary for the code and I’m not sure how this even simulates the original if statement.

Posted on Categories Articles

## approximation – How i can prove following statement?

Consider following greedy modification to the generic Ford-Fulkerson
augmenting path algorithm.Instead of maintaining a residual graph,
just reduce the capacity of edges along the augmenting path! In
particular, whenever we saturate an edge, just remove it from the
graph.

``````GREEDYFLOW(G, c, s, t):
for every edge e in G
f (e)=0
while there is a path from s to t
P=an arbitrary path from s to t
F=minimum capacity of any edge in P
for every edge e in P
f (e)=f (e)+ F
if c(e) = F
remove e from G
else
c(e)=c(e)- F
``````

return f

For simplicity this algorithm don’t consider augmenting-path.
Suppose Optimal solution is $$f^*$$ now
i have an example such that give us $$frac{1}{2}f^*$$ ,but i want prove that this algorithm can’t give us any approximation factor of optimal solution.Any hints will be appreciated.

Posted on Categories Articles

## f# – How to apply multiple filters in one statement

Nope, that’s pretty much the way.

If you really, really want to make this shorter and less cluttered, and if you face similar situations multiple times in your codebase, you could make yourself a special operator for combining predicates:

``````let (.&&.) f g c = f c && g c
``````

Then you can use this operator in your filter:

``````|> Seq.filter (needSpecialDocument .&&. wantToMoveTo)
``````

But base on my own experience I wouldn’t advise this. You make the program slicker and cooler looking, but you’re losing some readability. Now whoever reads your program will have to look up the meaning of `.&&.`. Programs are read more often than they are written.

Posted on Categories Articles

## php – Date is being sent as 0000-00-00 and returned as 11/30/-0001 when I use SQL update statement

``````<?php
include 'db.php';
\$WAGE = 14;
\$TAX = 0.01;
\$SS = 0.062;
\$MEDI = 0.0145;
\$GOAL = 0.75;

if(\$_SERVER('REQUEST_METHOD') === "POST") {
// Variables
\$id = htmlspecialchars(\$_POST('id'));
\$begDate = htmlspecialchars(\$_POST('date1'));
\$endDate = htmlspecialchars(\$_POST('date2'));
\$hours = htmlspecialchars(\$_POST('hours'));
\$total = number_format(\$hours * \$WAGE, 2, '.', '');
\$taxDeducted = number_format(\$total * \$TAX, 2,'.', '');
\$SSDeducted = number_format(\$total * \$SS, '2', '.', '');
\$MEDIDeducted = number_format(\$total * \$MEDI, '2', '.', '');
\$deducted = number_format(\$taxDeducted + \$MEDIDeducted + \$SSDeducted, 2, '.', '');
\$total -= number_format(\$deducted, 2, '.', '');
\$save = number_format(\$GOAL * \$total, 2, '.', '');
\$date = \$_POST('date1');
// SQL
\$sql = "UPDATE hours SET begDate=\$date, endDate=\$endDate, hours=\$hours, deducted=\$deducted, save=\$save, total=\$total WHERE id=\$id;";

// EXECUTE
\$stmt = \$conn->prepare(\$sql);
\$stmt->execute();
}

?>``````
``````<?php
include 'db.php';
if(isset(\$_GET('id'))) :
\$id = \$_GET('id');
\$sql = "SELECT * FROM hours WHERE id=\$id;";
\$stmt = \$conn->prepare(\$sql);

\$stmt->execute();
\$result = \$stmt->fetchAll();
foreach(\$result as \$res) :
\$begDate = \$res('begDate');
\$endDate = \$res('endDate');
\$hours = \$res('hours');
endforeach;
?>
<div class="container form bg-light p-5">
<form action="editForm.php" method="post">
<input type="hidden" name="id" value="<?= \$id; ?>" id="id">
<div class="row">
<div class="form-group col-md-5">
<input type="date" name="date1" id="date1" value="<?=\$begDate;?>"  class="form-control" required>
</div>
<div class="col-md-2 text-center">
<h3>TO</h3>
</div>
<div class="col-md-5 form-group">
<input type="date" name="date2" id="date2" value="<?=\$endDate;?>" class="form-control" required>
</div>
</div>

<div class="row">
<div class="col-md-3 form-group mx-auto mt-5">
<input class="form-control" value="<?= \$hours;?>" type="float" name="hours" id="hours" placeholder="Hours this period" required>
</div>
</div>

<div class="row text-center mt-5">
<div class="form-group col-md-3 mx-auto">
<input type="submit" value="SUBMIT" name="submit" class="btn btn-secondary">
</div>
</div>
</form>
</div>
<?php endif; ?>

<script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<script>
\$('form').on('submit', function(e) {
e.preventDefault();
\$.ajax({
url: 'editForm.php',
method: 'post',
data: \$('form').serialize()
})
.done(function(res, status) {
if(status == 'success') {
window.location.href = 'index.php';
}
})
.fail(function(res, status) {
if(status == 'error') {
console.log('error');
}
});
})

</script>
<?php include 'footer.php'; ?>``````
Posted on Categories Articles

## The problem

I have a List with loads of rows and I’m doing a workaround in Python to fetch them without exceding the list view threshold. So far I managed to do this by limiting the ID range of the results, like so:

``````<...>/_api/Web/lists/GetByTitle('<ListName>')/Items?\$select=ID&\$top=5000&\$orderby=ID&\$filter=ID ge 1 and ID le 5000
``````

And then I change the numbers of ‘ID’ column from 1~5000 to 5001~10000, and so on…

## Some Queries

So this query here works fine:

``````<...>/_api/Web/lists/GetByTitle('<ListName>')/Items?\$select=*&\$top=5000&\$orderby=ID&\$filter=ID ge 20001 and ID le 25000 and TextField eq 'Some text'
``````

And I manage to get 5000 rows from each request made like this (even though there are more than 5000 rows with ‘Some text’ inside the ‘TextField’ column).

But if I try this one here:

``````<...>/_api/Web/lists/GetByTitle('<ListName>')/Items?\$select=*&\$top=5000&\$orderby=ID&\$filter=ID ge 20001 and ID le 25000 and DateField gt '2020-09-12T00:00:00'
``````

It raises me the limit exception. And if I change the date to a day that I know it’ll rerturn less then 5000 rows, it runs just fine.

## In Sum

I’m limiting the range with the ID column of SharePoint list so it doesn’t exceed the view threshold, but it doesn’t seem consistent.

This is the template i’m using, adding things at the end, and only changing the range until the list is over:

``````<...>\$filter=ID ge 1 and ID le 5000 and <other query options...>
``````

Any ideas on why SharePoint thinks I’m trying to fetch more than 5000 rows at once? Thanks in advance!

Posted on Categories Articles

## javascript – Improving or replacing a long if statement

I have a an if statement that works just fine, however, it has become a bit long and I need help to figure out how I can reduce the lines of code and thereby the readability.

I have a `defaultMonth` and set of `months` and a corresponding `price`. I need to add or reduce the price depending on the `defaultMonth` and `month` selected by the user.

Here are some examples of the output I need (note the interval is the same):

If default month is 60 – set price accordingly:

``````Month    -     Price
60             0.0
48             0.1
36             0.2
24             0.35
12             0.5
``````

If default month is 48 – set price accordingly:

``````Month    -     Price
60             -0.1
48             0.0
36             0.1
24             0.25
12             0.4
``````

If default month is 36 – set price accordingly:

``````Month    -     Price
60             -0.2
48             -0.1
36             0.0
24             0.15
12             0.3
``````

The way I’ve built it now is with an if statement for each default month and nested ifs for each month.

``````if (defaultMonth === 60) {
if (month === 60) {
this.price += 0.0
}
if (month === 48) {
this.price += 0.1
}
if (month === 36) {
this.price += 0.2
}
if (month === 24) {
this.price += 0.35
}
if (month === 12) {
this.price += 0.5
}
}
if (defaultMonth === 48) {
if (month === 60) {
this.price -= 0.1
}
if (month === 48) {
this.price += 0.0
}
if (month === 36) {
this.price += 0.1
}
if (month === 24) {
this.price += 0.25
}
if (month === 12) {
this.price += 0.4
}
}
if (defaultMonth === 36) {
if (month === 60) {
this.price -= 0.2
}
if (month === 48) {
this.price -= 0.1
}
if (month === 36) {
this.price += 0.0
}
if (month === 24) {
this.price += 0.15
}
if (month === 12) {
this.price += 0.3
}
}
if (defaultMonth === 24) {
if (month === 60) {
this.price -= 0.35
}
if (month === 48) {
this.price -= 0.25
}
if (month === 36) {
this.price -= 0.15
}
if (month === 24) {
this.price += 0.0
}
if (month === 12) {
this.price += 0.15
}
}
if (defaultMonth === 12) {
if (month === 60) {
this.price -= 0.5
}
if (month === 48) {
this.price -= 0.4
}
if (month === 36) {
this.price -= 0.3
}
if (month === 24) {
this.price -= 0.15
}
if (month === 12) {
this.price += 0.0
}
}
``````

Posted on Categories Articles

## Convert an IF statement in Mixed Integer Programming

I want to convert an IF statement for my optimization problem. I want to minimize the total price. I want 800 tones of salt and 3 suppliers offer me their prices.

Supplier $$1$$ offers me $$100$$ tones at $$\150$$ a tone.

Supplier $$2$$ offers me $$400$$ tones at $$\170$$ a tone, if I take $$300$$ tones (or more)the price drops to $$\150$$.

Supplier $$3$$ offers me $$1600$$ tones at $$\170$$ a tone.

Here is my model without the if statement :

$$x_i$$ is an integer variable representing the quantity bought to the supplier $$i$$,
$$p_i$$ is the price of the supplier $$i$$, $$c_i$$ is the maximal capacity offered by the supplier $$i$$.

$$Min( p_1times x_1 + p_2times x_2 + p_3times x_3)$$

$$s.t. x_1 + x_2 + x_3 = 800$$

$$x_1 leq 100$$

$$x_2 leq 400$$

$$x_3 leq 1600$$

Now I want to use the Big M method the convert my if statement but I don’t know how to do it.
I tried this method : Express a “complex” IF-Statement to Linear Programming to find the constraints but I don’t know how to modify my prices. I tried this :

If $$x_2 geq 300$$, Then $$p_2 = 150$$, Else $$p_2 = 170$$.

i.e.

If $$x_2 geq 300$$, Then $$b = 1$$, Else $$b = 0$$ and $$p_2 = 150b + 170(1-b)$$

In addition to this I code in python the the mip library, do you know a better library to do this?

Thanks a lot !

Posted on Categories Articles