cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
aarnav
Frequent Visitor

Default value if lookup doesn't find any record

Hi all,

I am trying to store value of  Level1 column of data source CustGrp  to a collection varGroup where customerNo equals 1234. 

I need to pass another field (say Level2) if below lookup fails to match any record in CustGrp data source.

 

Collect(varGroup,LookUp(CustGrp,CustomerNo = '1234',Level1));

 

is this possible?

 

Thanks,

2 ACCEPTED SOLUTIONS

Accepted Solutions
PVosEska
Resolver IV
Resolver IV

Hi @aarnav , how is this?

 

With the With() Function, you can create a temporary variable just during the execution of the formula. If you put the LookUp() in this with, you can check the result afterwards and handle it.

 

Example:

With(
    {
        tempvar: LookUp(
                    CustGrp, 
                    customerNo = 1234,
                    Level1
                 )
     },
     If(
         !IsBlank(tempvar),
         <Collect here>,
          IsBlank(tempvar),
         <other collect here>
     )
)

 

Good luck!

View solution in original post

zmorek
Super User
Super User

With(LookUp(CustGrp,CustomerNo=1234), Collect(varGroup,Coalesce(Level1, Level2)))

View solution in original post

2 REPLIES 2
PVosEska
Resolver IV
Resolver IV

Hi @aarnav , how is this?

 

With the With() Function, you can create a temporary variable just during the execution of the formula. If you put the LookUp() in this with, you can check the result afterwards and handle it.

 

Example:

With(
    {
        tempvar: LookUp(
                    CustGrp, 
                    customerNo = 1234,
                    Level1
                 )
     },
     If(
         !IsBlank(tempvar),
         <Collect here>,
          IsBlank(tempvar),
         <other collect here>
     )
)

 

Good luck!

zmorek
Super User
Super User

With(LookUp(CustGrp,CustomerNo=1234), Collect(varGroup,Coalesce(Level1, Level2)))

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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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
Top Kudoed Authors
Users online (1,847)