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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Answered

CountIf in Filter

(0) ShareShare
ReportReport
Posted on by 14

Hello,

 

I have two dataverse tables: Rooms (Name, Capacity) and RoomBookings (Name, Date, Room)

 

Now I'm trying to create a screen where users can book a room. First they select the date. Afterwards I want the next dropdown to only show the rooms that have capacity left on this date.

 

Therefore I tried this filter on the "select room"-drowdown to count the bookings of each room on the selected date:

 

Filter(
 RoomsCollection, 
 'Capacity' > CountIf(RoomBookingsCollection, 'Room'.'Name' = 'Name' && 'Date' = DateValue1.SelectedDate)
)

 

 

OnVisible of Screen:

 

ClearCollect(RoomsCollection,[@Rooms]);
ClearCollect(RoomBookingsCollection,[@RoomBookings]);

 

 

Problem is, that the formula inside CountIf is obviously wrong.

'Name' refers to RoomBookingsCollection instead of RoomsCollection. Therefore the condition doesn't do what it's supposed to do...

 

So what's the right way to do this?

Categories:
I have the same question (0)
  • Verified answer
    MichelK Profile Picture
    120 on at

    Hello @alondattner,

     

    Could you try the following:

    Filter(
     RoomsCollection, 
     'Capacity' > CountIf(RoomBookingsCollection, 'Room'.'Name' = RoomsCollection[@Name] && 'Date' = DateValue1.SelectedDate)
    )

    Or the following:

    Filter(
     RoomsCollection As RoomRecord, 
     'Capacity' > CountIf(RoomBookingsCollection, 'Room'.'Name' = RoomRecord.'Name' && 'Date' = DateValue1.SelectedDate)
    )

     

    Let me know if this helps!

  • alondattner Profile Picture
    14 on at

    Hi @MichelK ,

    thanks for your solution, it worked with one small adjustment: Changing 'Capacity' to RoomRecord.'Capacity'

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard