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

If statement in ForAll

Hello Team,

 

I have below formula working fine. All I need to do is add if statement within ForAll. I have to compare timestamp in SQL Table and gallery and I have that condition ready but couldn't figure it our where I can add in the below formula.

 

Working formula :

 

ForAll(Gallery.AllItems,Patch('SQLTable',First(Filter('SQLTable',SQLColumn1=Label1.Text)),{SQLColumn2:Label2.Text,SQLColumn3:Label3.Text,SQLColumn4:Label4.Text,SQLColumn5:Label5.Text}))

 

Wants to add below if statement to above formula

 

If( TimeValue(Replace( SQLColumnValue, 1, 11, "" )) < TimeValue(Replace( GalleryColumnValue(Label), 1, 11, "" )),
    "Patch",
    "Don't Patch"
)

 

Please help.

Thanks.

3 REPLIES 3
Super User III
Super User III

@vshah804 

ForAll(
    Gallery.AllItems,
    If(
        TimeValue(Replace( SQLColumnValue, 1, 11, "" )) < TimeValue(Replace( GalleryColumnValue(Label), 1, 11, "" )),
        Patch(
            'SQLTable',
            First(Filter('SQLTable',SQLColumn1=Label1.Text)),
           {SQLColumn2:Label2.Text,SQLColumn3:Label3.Text,SQLColumn4:Label4.Text,SQLColumn5:Label5.Text}
        )
    )
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

@mdevaney  - Thank you for your prompt response. I'm not sure if this is going to work.

 

The reason is, first I have to filer to find the correct record based on First(Filter('SQLTable',SQLColumn1=Label1.Text))

 

Once, I find the correct record, then if condition comes in. Then I have to compare second column of the record of source and destination with if condition. If condition is true, I want to Patch. 

 

I hope I'm clear enough. Thank you.

@vshah804 

You could retrieve the record and store it in the variable as the 1st line of code in your 2nd argument to FORALL.

Set(myRecord, First(Filter('SQLTable',SQLColumn1=Label1.Text)))

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (49,749)