cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TCH
Level: Powered On

Multiple conditions

Hi guys, 

So i have a button that needs to patch to a SharePoint List, I need it to first check if the list already has that item in it, then check if the value of a checkbox is True, then after this I need it to patch a Name an a Date depending on the jobtitle of the user. If the jobtitle equals "Praktikant" it needs to just patch this, however, if it is not, then I need it to just patch their name and the date? I have tried the formula as seen under the text, however, in this case it patches both. Anyone got any ideas on how to make sure that it patches "Praktikant" if this is the jobtitle, but then their actual name if it is not 🙂 

If(
    And(
        IsBlank(
            LookUp(
                Onsdag;
                Medarbejdernr = Medanr.Text;
                false
            )
        );
        'Onsdag()'.Value = true
    );
    'Office365-brugere'.MyProfile().JobTitle = Label6.Text;
    Set(
        gBlItemPatched;
        Patch(
            Onsdag;
            Defaults(Onsdag);
            {
                Title: Label6.Text;
                Dato: Dato1.Text
            }
        )
    );
    Set(
        gBlItemPatched;
        Patch(
            Onsdag;
            Defaults(Onsdag);
            {
                Title: User().FullName;
                Medarbejdernr: Medanr.Text;
                Dato: Dato1.Text
            }
        )
    )
)

 

Thanks In advance. 
- Tobi 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Multiple conditions

Hi @TCH ,

Based on the formula you provided, I think there is something wrong with it.

 

I have made a test on my side, please consider modify your formula as below:

If(
   IsBlank(LookUp(Onsdag; Medarbejdernr = Medanr.Text)) && 'Onsdag()'.Value = true;
   If(
       Office365Users.MyProfile().JobTitle = Label6.Text;
       Set(
           gBlItemPatched;
           Patch(
                 Onsdag;
                 Defaults(Onsdag);
                 {
                   Title: Label6.Text;
                   Dato: Dato1.Text
                 }
           )
      );
      Set(
          gBlItemPatched;
          Patch(
                Onsdag;
                Defaults(Onsdag);
                {
                  Title: User().FullName;
                  Medarbejdernr: Medanr.Text;
                  Dato: Dato1.Text
                }
         )
      )
   )
)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Eelman
Level 10

Re: Multiple conditions

@TCH I found it a little hard to follow your code because you are using semi-colon's instead of commas throughout your code. I didn't know you could do that? I guess if it works then you can?

 

Anyway, with this in mind, I think you need a comma to separate off your 'Else' statement. See below, try changing this semi-colon to a comma and see if that works?

 
Super User
Super User

Re: Multiple conditions

@Eelman 

Just wanted to chime in and let you know the reason semi-colon works for the OP is because of their language settings.  I am not sure which languages do this but so far I have experienced it for forum members whose language is Portugese and Spanish.  See the picture below for more details.

 

Capture.PNG

 

More info at the Official MS Docs for global apps

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/global-apps

Eelman
Level 10

Re: Multiple conditions

@mdevaney thanks mate, that's something I wasn't aware of.

 

 

AnneZC
Level: Powered On

Re: Multiple conditions

Hi @TCH ,

It looks to me like you are missing a second If statement (shown in the logic below in blue).

 

Is your logic supposed to be: 

If (the item does not already exist and the check box is true)

Then

      If the Job Title = Label6.Text

      Then Create item with Title and Date

      Else Create item with Name and Date

 

 

 

Community Support Team
Community Support Team

Re: Multiple conditions

Hi @TCH ,

Based on the formula you provided, I think there is something wrong with it.

 

I have made a test on my side, please consider modify your formula as below:

If(
   IsBlank(LookUp(Onsdag; Medarbejdernr = Medanr.Text)) && 'Onsdag()'.Value = true;
   If(
       Office365Users.MyProfile().JobTitle = Label6.Text;
       Set(
           gBlItemPatched;
           Patch(
                 Onsdag;
                 Defaults(Onsdag);
                 {
                   Title: Label6.Text;
                   Dato: Dato1.Text
                 }
           )
      );
      Set(
          gBlItemPatched;
          Patch(
                Onsdag;
                Defaults(Onsdag);
                {
                  Title: User().FullName;
                  Medarbejdernr: Medanr.Text;
                  Dato: Dato1.Text
                }
         )
      )
   )
)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,492)