cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ReyOrtiz
Helper II
Helper II

Issue with command with multiple If statement

Hi all
I'm hoping anyone can assist me with this mess :). I trying to create a logic to an SP list using power apps, but I am using several If statements and one if it works perfect, but when I try to add the rest in different ways, I can't; I keep giving myself an error. below is what I wrote that works

 

If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value ="Within the next two weeks (urgent)" && ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 15), Days))

 

below is the rest, with the added statements.

 

If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value ="Within the next two weeks (urgent)" && ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 15), Days)), If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 29), Days)), If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) -50 ), Days)), If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value ="Within the next two weeks (urgent)" && ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 15), Days)), If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 29), Days)), If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today "&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) -50 ), Days))

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@ReyOrtiz 

Cleaning it up a bit:

 

With({**bleep**:"New Initiative/Program" 
      gov:"Add an item onto the Collection Operations Governance Calendar ONLY"
      val:ThisItem.'Purpose of Request'.Value
      ap:ThisItem.'Approval Status'.Value="Approved",
      tf:ThisItem.'Expected Timeframe'.Value,
      da:DateAdd(ThisItem.Date,-1,
      wk:(Weekday(ThisItem.Date, Monday)
       },
  If( 
     val=**bleep**&&ap&&tf="Within the next two weeks (urgent)", da*wk-15),
     val=**bleep**&&ap&&tf="Four to six weeks from today", da*wk-29), //*one is wrong
     val=**bleep**&&ap&&tf="Four to six weeks from today", da*wk-50),  //*one is wrong
     val=gov&&ap&&tf="Within the next two weeks (urgent)",da*wk-15),
     val=gov&&ap&&tf="Four to six weeks from today", da*wk-29), //*one is wrong
     val=gov&&ap&&tf="Four to six weeks from today ", da*wk- 50) //* one is wrong

I have no idea why the editor replaced "ni" on my formula with **bleep**

 

View solution in original post

4 REPLIES 4
Drrickryp
Super User
Super User

@ReyOrtiz 

Please review your conditions and if I am right, please correct it.  It appears he text in green are identical and the text in pink are identical but the results are different(Underlined and italic). 

If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value ="Within the next two weeks (urgent)" && ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 15), Days)),

If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 29), Days)),

If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) -50 ), Days)),

If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value ="Within the next two weeks (urgent)" && ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 15), Days)),

If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 29), Days)), If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today "&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) -50 ), Days))

Drrickryp
Super User
Super User

@ReyOrtiz 

Please review your conditions and if I am right, please correct it.  It appears he text in green is identical and the text in pink is identical but the results are different(Underlined and italic). 

If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value ="Within the next two weeks (urgent)" && ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 15), Days)),

If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 29), Days)),

If(ThisItem.'Purpose of Request'.Value="New Initiative/Program" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) -50 ), Days)),

If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value ="Within the next two weeks (urgent)" && ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 15), Days)),

If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today"&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) - 29), Days)), If(ThisItem.'Purpose of Request'.Value="Add an item onto the Collection Operations Governance Calendar ONLY" && ThisItem.'Expected Timeframe'.Value = "Four to six weeks from today "&& ThisItem.'Approval Status'.Value="Approved",DateAdd(ThisItem.Date, -1 * (Weekday(ThisItem.Date, Monday) -50 ), Days))

Drrickryp
Super User
Super User

@ReyOrtiz 

Cleaning it up a bit:

 

With({**bleep**:"New Initiative/Program" 
      gov:"Add an item onto the Collection Operations Governance Calendar ONLY"
      val:ThisItem.'Purpose of Request'.Value
      ap:ThisItem.'Approval Status'.Value="Approved",
      tf:ThisItem.'Expected Timeframe'.Value,
      da:DateAdd(ThisItem.Date,-1,
      wk:(Weekday(ThisItem.Date, Monday)
       },
  If( 
     val=**bleep**&&ap&&tf="Within the next two weeks (urgent)", da*wk-15),
     val=**bleep**&&ap&&tf="Four to six weeks from today", da*wk-29), //*one is wrong
     val=**bleep**&&ap&&tf="Four to six weeks from today", da*wk-50),  //*one is wrong
     val=gov&&ap&&tf="Within the next two weeks (urgent)",da*wk-15),
     val=gov&&ap&&tf="Four to six weeks from today", da*wk-29), //*one is wrong
     val=gov&&ap&&tf="Four to six weeks from today ", da*wk- 50) //* one is wrong

I have no idea why the editor replaced "ni" on my formula with **bleep**

 

@Drrickryp
You were right; the one with -50 was supposed to be Seven weeks or more, but I used your cleanup version, and the only thing I did was a switch - to +, which is working fine. Thank you for the help and for showing me this way to do formulas.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (2,958)