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

Help with proper use of If( and With(

Hello,
Could you help me to use this If( with with(

 

 

this is code

 

With(
If(
IsBlank(TextInput1.Text);
Sort(
Filter(
Nipon_P1;
'Estado docto'="Comprometido"
);
Numero_docto;
Descending
);
!IsBlank(TextInput1.Text);
Sort(
Filter(
Nipon_P1;
Numero_docto=(TextInput1.Text)

);
Ubicacion;
Descending
)
{
records:Nipon_P1
};
ForAll(
Sequence(CountRows(records));
Patch(
Last(
FirstN(records;Value));
{rowNumber: Value}


)

)
)
)

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Richard95 ,

Something like this

With(
   {
      wList:
      Sort(
         Filter(
            Nipon_P1;
            'Estado docto' = "Comprometido" &&
            (
               IsBlank(TextInput1.Text) ||
               Numero_docto = TextInput1.Text
            )
         );
         If(
            IsBlank(TextInput1.Text);
            Ubicacion;
            Numero_docto
         );
         Descending
      )
   },
   ForAll(
      Sequence(CountRows(wList));
      Patch(
         Last(
            FirstN(
               wList;
               Value
            )
         );
         {RowNumber: Value}
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

2 REPLIES 2
WarrenBelz
Super User
Super User

Hi @Richard95 ,

Something like this

With(
   {
      wList:
      Sort(
         Filter(
            Nipon_P1;
            'Estado docto' = "Comprometido" &&
            (
               IsBlank(TextInput1.Text) ||
               Numero_docto = TextInput1.Text
            )
         );
         If(
            IsBlank(TextInput1.Text);
            Ubicacion;
            Numero_docto
         );
         Descending
      )
   },
   ForAll(
      Sequence(CountRows(wList));
      Patch(
         Last(
            FirstN(
               wList;
               Value
            )
         );
         {RowNumber: Value}
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Richard95
Helper I
Helper I

Hello, thank you very much, it worked perfectly, I only made a few adjustments and it is fully operational

 

😄

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,781)