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 / Working with collections
Power Apps
Answered

Working with collections

(0) ShareShare
ReportReport
Posted on by 565

Hi,

 

I am working in a holidays app and I need to get the current balance of days for each employee.

I have these collections, I need to get the result "colBalance":

 

EmilioRoqueta69_1-1718373357023.png

The colBalance is the sumatoria of the days of the Year (A) plus (if the employee has) the pending days at the colPreviousYear (B) less the days requested in colHolidays (C)

 

A + B - C

 

Here the sample collections:

 

ClearCollect(colYear, {Country: "USA", Year: 2024, Days:20});

ClearCollect(colPreviousYear,{User: "Emilio", PendingDays:10},{User: "Paul", PendingDays:5});

ClearCollect(colHolidays,
{User:"Emilio", Country:"USA", Year:2024, DaysRequested: 10},
{User:"Emilio", Country:"USA", Year:2024, DaysRequested: 5},
{User:"Linda", Country:"USA", Year:2024, DaysRequested: 5},
{User:"Linda", Country:"USA", Year:2024, DaysRequested: 7},
{User:"Paul", Country:"USA", Year:2024, DaysRequested: 25},
{User:"Peter", Country:"USA", Year:2024, DaysRequested: 15})

 

Is it possible? Thanks for any help!!

 

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    Assuming that you have a list of users somewhere (such as in a collection like the following):

    ClearCollect(
     colUsers,
    { Country: "USA", User: "Emilio" },
    { Country: "USA", User: "Peter" },
    { Country: "USA", User: "Linda" },
    { Country: "USA", User: "Paul" },
    { Country: "USA", User: "John" })

    You can use an expression like this one to get the balance:

    ClearCollect(
     colBalance,
     ForAll(
     colUsers As users,
     With(
     {
     balanceForYear: LookUp(colYear, Year = Year(Today()) And Country = users.Country, Days),
     balanceForPreviousYear: Coalesce(LookUp(colPreviousYear, User = users.User, PendingDays), 0),
     daysRequested: Sum(Filter(colHolidays, Country = users.Country And Year = Year(Today()) And User = users.User), DaysRequested)
     },
     {
     User: users.User,
     Days: balanceForYear + balanceForPreviousYear - daysRequested
     }
     )
     )
    )

    Hope this helps!

  • EmilioRoqueta69 Profile Picture
    565 on at

    Thank you so much Carlos!

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 531 Most Valuable Professional

#2
Haque Profile Picture

Haque 261

#3
Kalathiya Profile Picture

Kalathiya 221 Super User 2026 Season 1

Last 30 days Overall leaderboard