web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problem trying to retu...
Power Apps
Answered

Problem trying to return a number from a Lookup

(1) ShareShare
ReportReport
Posted on by 37

Hi,

 

I have a formula that needs to count how many candidates are booked on a course, and then to change the status to "Full" once the max capacity is reach. The max capacity is defined by a separate data source that holds the venues' details.

 

My formula is struggling to recognise a number from a LookUp. If I bypass the LookUp and type the number in my formula, it works, but each venue has a different capacity.

 

The format of the column my formula is Patching is Text.

 

 

If(CountRows(Filter(Class_registrations,Course_ID=ThisItem.Course_ID And 'Attendance Type'="Candidate"))>=
LookUp(ODP_Courses_Lists,Course_ID_Number= ThisItem.Course_ID,Max_Cand) ,
Patch(ODP_Courses_Lists,LookUp(ODP_Courses_Lists,Course_ID_Number=ThisItem.Course_ID),
{Course_Status:"Full"}))

 

PA_formula_1.PNG

 

Thanks, Andy

Categories:
  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @ARV84Z ,

    I assume you are running this from a control inside a Gallery or Form as you refer to ThisItem. If you put this on a Text Label also inside the Form/Gallery, what do you see ?

    LookUp(
     ODP_Courses_Lists,
     Course_ID_Number = ThisItem.Course_ID
    ).Max_Cand

    I also assume Max_Cand is a number column in ODP_Courses_Lists.

  • ARV84Z Profile Picture
    37 on at

    Hi @WarrenBelz ,

    Yes, this is run inside a gallery. If I create a text label and add the code I get a number ,"8".

    Max_Cand is a text column, not a number column.

     

    Andy

  • ARV84Z Profile Picture
    37 on at

    @WarrenBelz , I changed the column type to number, rather than text and it works. But my patch code to add the number in the first instance is now an issue.

     

    How do I patch a number column with a label?

     

    I have tried this:

    Max_Can:txtinpMaxCan

    but it needs a something after to define it. All I have is '.Text', but this can't be right?

     

    Is it my label format?

  • Verified answer
    WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @ARV84Z ,

    The whole issue here is that you need to turn the text value into a number, but I also have some improvement suggestions

    With(
     {
     _Reg:
     Filter(
     Class_registrations,
     Course_ID = ThisItem.Course_ID And 
     'Attendance Type' = "Candidate"
     ),
     _Max:
     Value(
     LookUp(
     ODP_Courses_Lists,
     Course_ID_Number = ThisItem.Course_ID
     ).Max_Cand
     )
     }
     If(
     CountRows(_Reg) >= _Max,
     Patch(
     ODP_Courses_Lists,
     LookUp(
     ODP_Courses_Lists,
     Course_ID_Number = ThisItem.Course_ID
     ),
     {Course_Status: "Full"}
     )
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • ARV84Z Profile Picture
    37 on at

    Amazing thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 432 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard