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 Apps
Answered

Collection Join

(0) ShareShare
ReportReport
Posted on by 565

Hi all,

 

I am creating a Holidays App, and I want to get the current balance of free days for each employee.

So, I have a table with the available days for each employee and the table of the holidays requests, and I need to get a collection with the balance of days.

EmilioRoqueta69_1-1716806960400.png

Thanks for any help!

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,966 Most Valuable Professional on at

    Hi @EmilioRoqueta69 ,

    Something like this should do it

    ClearCollect(
     colResult,
     ShowColumns(
     AddColumns(
     Employees,
     Available_Days,
     AvailableDays - 
     LookUp(
     Holidays As _Hol,
     _Hol.User = User
     ).RequestedDays
     ),
     User,
     Available_Days
     )
    )

     

    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

  • EmilioRoqueta69 Profile Picture
    565 on at

    Thank you Warren, but there is some issue with the Lookup

     

    EmilioRoqueta69_0-1716815010907.png

     

    ClearCollect(colEmployees,
    {User: "Emily" , AvailableDays:22},
    {User: "John" , AvailableDays:20},
    {User: "Peter" , AvailableDays:5});
    ClearCollect(colHolidays,
    {User: "Emily" , RequestedDays:10},
    {User: "Emily" , RequestedDays:5},
    {User: "John" , RequestedDays:10},
    {User: "John" , RequestedDays:2});
    ClearCollect(
       colResult,
       ShowColumns(
          AddColumns(
             colEmployees,
             Available_Days,
             AvailableDays -
              Lookup(
                colHolidays As _Hol,
                _Hol.User = User
             ).RequestedDays
          ),
          User,
          Available_Days))

     

  • EmilioRoqueta69 Profile Picture
    565 on at

    I made this change but it only takes the first record of each user at colHolidays.

     

    ClearCollect(
       colResult,
       ShowColumns(
          AddColumns(
             colEmployees,
             Available_Days,
             AvailableDays - Sum(LookUp(colHolidays As _Hol, User = _Hol.User).RequestedDays)
          ),
          User,
          Available_Days))
  • EmilioRoqueta69 Profile Picture
    565 on at

    It works!

     

    ClearCollect(colEmployees,
    {User: "Emily" , AvailableDays:22},
    {User: "John" , AvailableDays:20},
    {User: "Peter" , AvailableDays:5});
    ClearCollect(colHolidays,
    {User: "Emily" , RequestedDays:10},
    {User: "Emily" , RequestedDays:5},
    {User: "John" , RequestedDays:10},
    {User: "John" , RequestedDays:2});


    ClearCollect(
       colResult,
       ShowColumns(
          AddColumns(
             colEmployees,
             Available_Days,
             AvailableDays - Sum(Filter(colHolidays As _Hol, User = _Hol.User),RequestedDays)
          ),
          User,
          Available_Days))
  • Verified answer
    WarrenBelz Profile Picture
    154,966 Most Valuable Professional on at

    Hi @EmilioRoqueta69 ,

    A small u in Lookup (should be LookUp) was the issue for your error, however I did not notice the multiple holiday requests and yes - this is the correct code with that in mind.

    ClearCollect( 
     colResult,
     ShowColumns(
     AddColumns(
     colEmployees, 
     Available_Days, 
     AvailableDays - 
     Sum(
     Filter(
     colHolidays As _Hol,
     _Hol.User = User 
     ),
     RequestedDays
     )
     ),
     User,
     Available_Days
     )
    )

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 510

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 281

Last 30 days Overall leaderboard