vendredi 1 octobre 2021

Excel Formula to sum the values from one column only if there are values in another column?

This is hard for me to explain and I'm not an expert. Sorry if this is confusing.

I have a worksheet that lists several items a customer could buy and I need the worksheet to create price and cost totals depending on what items they select. I have the price total but having issues with the costs because I only need the sum of the costs for items that have a price in the respective cell.

Below is a small sample of my table. Basically, I need a formula to sum up the cost (column B) if there is a price in Column C.

I started doing this but the string would be insanely long: IF(C2<>"",B2,0)+IF(C3<>"",B3,0)+... Is there a formula to make this work for several rows together?

See sample here.

If you recommend doing something completely differently, I'd love any suggestions.

Thank you for your help.

Adding group policies to new AD user

Is there a way to add group policies to a new AD user in the same script? When I add the function of creating the new user to a button it only seems to make the new user at the end of the script, when I try to add the group policy to the variable $userName it cant find the user in AD. Can I get the new user to be made before the script ends? I also have to also declare the variable again for some reason.

function Creation {

$firstName = $textbox_FirstName.Text
$middleName = $textbox_MiddleName.Text
$lastName = $textbox_Surname.Text
$jobCode = $textbox_JobCode.Text
$Password = $textbox_Password.Text | ConvertTo-SecureString -AsPlainText -Force

if ($dropdown_FirstOU.Text -eq "Aberdeen") {
    $OU = "OU=Aberdeen,OU=UK,DC=Kuehne-Nagel,DC=local"
} elseif ($dropdown_FirstOU.Text -eq "Kingpin") {
    $OU = "OU=Kingpin,OU=UK,DC=Kuehne-Nagel,DC=local"
}

if (($dropdown_FirstOU.Text -eq "Banbury") -and ($dropdown_SecondOU.Text -eq "Business Development")) {
    $OU = "OU=Business Development,OU=Banbury,OU=UK,DC=Kuehne-Nagel,DC=local"
} elseif (($dropdown_FirstOU.Text -eq "Banbury") -and ($dropdown_SecondOU.Text -eq "CTI/Property")) {
    $OU = "OU=CTI / Property,OU=Banbury,OU=UK,DC=Kuehne-Nagel,DC=local"
}

if (($dropdown_FirstOU.Text -eq "London") -and ($dropdown_SecondOU.Text -eq "Heathrow03") -and ($dropdown_ThirdOU.Text -eq "Heathrow03")) {
    $OU = "OU=Heathrow03,OU=Heathrow03,OU=London,OU=UK,DC=Kuehne-Nagel,DC=local"
}

$Telephone = $textbox_Telephone.Text

if ($textbox_MiddleName.Text -eq "") {
    $displayName = "$lastName, $firstName"
    $userName = "$firstName.$lastName"
} else {
    $displayName = "$lastName, $firstName $middleName"
    $userName = "$firstName.$middleName.$lastName"
}

New-ADUser -Name "$userName" -GivenName "$firstName" -Surname "$lastName" -Initials "$middleName" -officephone "$Telephone" -samAccountName "$userName" -AccountPassword $Password -Enabled $True -DisplayName "$displayName / Kuehne + Nagel / $jobCode" -userPrincipalName "$userName@kuehne-nagel.local" -Path "$OU"
Set-ADUser -Identity $userName -ChangePasswordAtLogon $true

}

function Template {

$firstName = $textbox_FirstName.Text
$middleName = $textbox_MiddleName.Text
$lastName = $textbox_Surname.Text

if ($textbox_MiddleName.Text -eq "") {
    $displayName = "$lastName, $firstName"
    $userName = "$firstName.$lastName"
} else {
    $displayName = "$lastName, $firstName $middleName"
    $userName = "$firstName.$middleName.$lastName"
}

if ($RadioButton_IFF.Checked) {
    Add-ADGroupMember -Identity "Test1" -Members $UserName
}

}

how can i add if condition image.url.present?

I have here four images, what I want if one of those images are empty to not showing it as missing. here's an image to explain more enter image description here

   <% [@car.image.url, @car.image2.url, @car.image3.url, @car.image4.url].each do |image| %>
              <%= link_to "javascript:void(0)", data: { image: image, zoom_image: image } do %>
                <%= image_tag image%>
              <% end %>
            <% end %>

Skip specific observations when using row_number() - R

I'm essentially after a "next" statement which I can use within a dplyr ifelse statement, although other R alternatives are also welcome.

Here's the code so far:

df1 <- data%>%
  arrange(Var1, Var2, Var3, Var4, Var5)%>%
  group_by(Var1)%>%
  distinct(Var1, Var2, Var3, Var4, Var5)%>%
  mutate(Var6 = ifelse(Var4 == "COMPLETE", row_number(), row_number()+1))

the output is (relevant version)

  | Var4         | Var6         |
  | ------------ | -------------|
  | COMPLETE     | 1            |
**| INCOMPLETE   | 3            |**
  | COMPLETE     | 3            |
  | COMPLETE     | 4            |
  | COMPLETE     | 5            |
**| INCOMPLETE   | 7            |**
  | COMPLETE     | 7            |
  | COMPLETE     | 8            |
  | COMPLETE     | 9            |


the intended output is


  | Var4         | Var6         |
  | ------------ | -------------|
  | COMPLETE     | 1            |
**| INCOMPLETE   | 2            |**
  | COMPLETE     | 2            |
  | COMPLETE     | 3            |
  | COMPLETE     | 4            |
**| INCOMPLETE   | 5            |**
  | COMPLETE     | 5            |
  | COMPLETE     | 6            |
  | COMPLETE     | 7            |

In summary, my goal is that when Var4 == INCOMPLETE I am able to ignore that row and continue with row_number().

Laravel - Element displaying twice while looping inside a condition

This is the example while looping

despite having a condition and relation many too many it seems that the case

  @foreach (\App\ClientDocument::where('id_client', $clients->id)->get() as $item)    
                  @if (\App\Document::where('id',$item->id_document)->get())
                  <a class="img-fluid " href="" download="" alt="" name="download"  > Telecharger </a>
            
                  @endif  
               @endforeach

Move all text values with the same ID field to separate columns

I would like to move all the comments (Column B3:B14) to be new columns against each unique ID (Column A3:A14).

The Desired Format shows the layout that I would like to get to.

enter image description here

Hopefully that makes sense.

Why my if and else if block is not running in my java code? [duplicate]

Why my if and else if block is not running in my java code? Here i given software engineering as input but web developer is getting printed. but actually software engineering only should be printed. Here if and else if condition is not working in setRole method. Can anyone help to sort this out?



 public class MyClass{
     String education;
     String role;
     Scanner sc=new Scanner(System.in);
 
     //Getters
     public String getEducation(){
         return education;
     }
     public String getRole(){
         return role;
     }
 
 
     //Setters
     public void setEducation(String newEducation){
         this.education=newEducation;
     }
     public void setRole(String newRole){
         this.role=newRole;
     }
     //Getting input from the user
     public void enterEducation(){
         System.out.println("Enter your education:");
         setEducation(sc.nextLine());
     }
     public void enterRole(){
         String[] arrayrole={"CEO","Web developer","Software engineer"};
         if(education=="software engineering"){
             setRole(arrayrole[2]);
         }
         else if(education=="MBA"){
             setRole(arrayrole[0]);
         }
         else{
             setRole(arrayrole[1]);
         }
     }
     public void play(){
        enterEducation();
         enterRole();
        
     }
     public void About(){
         System.out.print("Your education is "+education+
         ". so,Your job role is "+role);
     }
     public static void main(String[] args){
         MyClass p=new MyClass();
         p.play();
         p.About();
 
     }
 }