cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

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
Super User
Super User

@Anonymous 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?

 

@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

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

 

 

AnneZC
Helper I
Helper I

Hi @Anonymous ,

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

 

 

 

v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,621)