dimanche 2 septembre 2018

Display "(Cell C4) Cell A2" if Cell C4 contains "HOT" or "WARM"

Here's what I currently have, I'm working on a small sales pipeline: Image

I need it to look like this in another sheet: image

I'm using this code:

=IF(OR('Sponsorship '!C4="HOT",'Sponsorship '!B4="WARM"),'Sponsorship '!A4,"")

I was going to attempt how to get the prefix WARM or HOT appended at a later time, but I'm already facing issues as I can't figure out how to get cells that do not meet either criteria (WARM/HOT) to just move on to the next row, rather than show blank. See image of what i mean:

Image

Your response would be greatly appreciated! Thank you!

Android app getting closed every time I am running this "if else" conditional statement in an Onclick listener for a button

I am a beginner in android, and currently I am working on an app which requires usage of a else if statement. Below is the code snippet of the same:

submit.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {


    if ((CCValue.equals("3") && MVValue.equals("3.5")) || (CCValue.equals("3") && MVValue.equals("4")) || (CCValue.equals("3") && MVValue.equals("5")) ||
      (CCValue.equals("4") && MVValue.equals("4.5")) || (CCValue.equals("4") && MVValue.equals("5")) || (CCValue.equals("5") && MVValue.equals("5"))) {

      thresholdValue = 1;

    } else {
      thresholdValue = 0;
    }

    threshold.setText(thresholdValue);

  }
});

Submit is the name of the button on which the user will click, and the compiler will go in the "if" statement. CCValue and MVValue are string variables, which I am saving from two spinners selected by the user. "thresholdValue" is an integer variable which will get value according to the if statement. Finally "threshold" is an EditText component.

Now I am trying to compare the values stored withing the string variables through the "if" condition. But every time whenever I am clicking on the submit button the app is getting crashed. What changes should I make to make this code run successfully?

PHP Reforce Search Engine

I have this Search option, where it looks for the Title and the Category Referent to the variable requested by the FORM.

//This could be Reference or Product Name
$name = mysqli_real_escape_string($con, sanitize($_GET['search']));

//this could be a specific category or Empty(used to reference number)
$category = mysqli_real_escape_string($con, sanitize($_GET['category']));
$x = 0; 
$q = str_replace(array("\\",";"), "", $name);  // remove ALL backslashes & remove ALL ";" -> for sql security: no (simple) injection of commands
$q = trim($q);
$search_exploded = explode(" ", $q);

foreach($search_exploded as $search_each ) { 

$x++; 

   if($x == 1) { 
         $wherearr[]= "ads_title LIKE '%$search_each%' AND category_id = '$category' AND ads_active = 1 AND ads_end = 0"; 
   } else {     
         $wherearr[]= "ads_title LIKE '%$search_each%' AND category_id = '$category' AND ads_active = 1 AND ads_end = 0"; 
   }

}

//$wherearr[] is used to create a new variable $construct to insert to SQL like "Select * from Where $construct"    

I want to able people to search also by product reference.

The goal is, when the person inserts the reference, it will automatically go to the product.

Add this field:

 $wherearr[]= "ads_reference LIKE '%$search_each%' AND ads_active = 1 AND ads_end = 0";

How can I do it using the form that I created before?

Python instance variable

I picked up these lines of code from a model answer to a textbook question

if self._initialSum == 0:
        initialSum = v1 + v2
        if initialSum in (2, 3, 12):
            return "LOSE"
        elif initialSum in (7, 11):
            return "WIN"
        else:
            return "CONTINUE"
    else:
        sum = v1 + v2
        if sum == 7:
            return "LOSE"
        elif sum == initialSum:
            return "WIN"
        else:
            return "CONTINUE"

I am trying to figure out of self.initialSum and initialSum are referencing the same variable. My beginner understanding is the main if block and else block each have a initialSum however the else block is referencing it before it is set. Or is it set by self._initialSum.

I hope I am making sense guys. Thanks in advance

Kimmy

Favorite food java program gone wrong

Here is my java program. Right now, the only way to kill the loop is to have the last column to be the longest. Here is the code:

package com.begg;

import java.util.*;

public class List {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String[][] food = {
                {"Bannana", "Apple", "Pear", "Orange"}, // fruits
                {"GreenBean", "Iceburg", "Spenach", "peas"}, // vegetables 
                {"Steak",   "Baccon", "Beef", "TurkeyB", "TurkeyBacon", "Chicken"} // meats

                /*
                 * Your longest part of your array should be the longest
                 * if it's not, using the length  of the column to end a loop may cause problems
                 * if you use the row instead, everything after the row three will execute  
                 * 
                 */


        };

        for(int row = 0; row < food.length; row++) {
            for (int col = 0; col < food[row].length; col ++) {
                System.out.print(food[row][col] + ", ");
            }
            System.out.println();
        }
        System.out.println("Enter your favorite out of the options above:");
        String k = sc.next();
        loop2:
        for(int row2 = 0; row2<food.length; row2++) {
            for (int col2 = 0; col2< food[row2].length; col2++) {
                test:
                if (k.equalsIgnoreCase(food[row2][col2])) {
                    System.out.println("Your favorite food is " + food[row2][col2]);
                    break loop2;

                }

                else if (!(k.equalsIgnoreCase(food[row2][col2])) & col2== 5 ) {
                    System.out.println("Yo have no favorite food");
                }
            }
        }

    }
}

Is there any way to print out "you have no food" without using the last column being the longest? Thanks!

R sampling with if statement and similar number of sample

I need to to create a sample from my dataframe and to do so I am using the code bellow.

 name <- sample(c("Adam","John","Henry","Mike"),100,rep = TRUE)
 area <- sample(c("run","develop","test"),100,rep = TRUE)
 id <- sample(100:200,100,rep = FALSE)

 mydata <- as.data.frame(cbind(id,area,name))


qcsample <- mydata %>%
  group_by(area) %>% 
  nest() %>%            
  mutate(n = c(20, 15, 15)) %>% 
  mutate(samp = map2(data, n, sample_n)) %>% 
  select(area, samp) %>%
  unnest()

Now, I am getting these results.

table(qcsample$area) 

develop     run    test 
     15      15      20 

--

table(qcsample$name)

Adam Henry  John  Mike 

    9     9    16    16 

I would like to create a sample that would have more or less the same number of samples for each name eg. Adam - 12, Henry - 12, John - 13, Mike - 13. How can I achieve that ? can I somehow request that the sample is equally distributed ?

Also, in this example I used function

sample_n

and specified number of samples.

I am anticipating that sometimes there will not be required number from a given group. In my example I am taking 20 samples from area called "test" but sometimes there will be only let's say 10 rows containing "test". The total number is 50 so I need to make sure if there are only 10 "test" the code has to automatically increase the others, so the sample would be "test" - 10, "run" - 20 and "develop" - 20. This can happen to any of the area so I need to test if there is enough rows to create the sample and increase other areas. If there is only 1 it can be added to any of the remaining areas or if the difference is 3 we add 1 to one area and 2 to the another one.

How could I check that taking into account all the possibilities ? I believe there are eight permutations in this case.

Thanks in advance A.

Python If else expected an indented block

I have the following code block

   def simple_get(url):
    try:
        page_response = requests.get(page_link, timeout=5)
        if page_response.status_code == 200:
        # extract
        else:
            print(page_response.status_code)
            # notify, try again
    except requests.Timeout as e:
        print("It is time to timeout")
        print(str(e))
    except # other exception

When I run it give me the following error File "", line 11 else: ^ IndentationError: expected an indented block

I dont understand why is the notebook still asking for indentation when I already have the "else" statement indented