cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

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
Highlighted
Community Support
Community Support

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
Highlighted
Community Champion
Community Champion

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?

 
Highlighted
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

Highlighted
Community Champion
Community Champion

Re: Multiple conditions

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

 

 

Highlighted
Helper I
Helper I

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

 

 

 

Highlighted
Community Support
Community Support

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
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,896)