cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Validating selected date on power apps with sharepoint list

Hello! I need some help with validating selected date on power apps with my sharepoint list.

 

Context: I am trying to create an app that can issue max. 2 tickets a day. So, when an individual selects a date on the power app, this formula will look through 2 columns on my sharepoint list, mainly 'Date column' and 'tickets column' (text formatted) to see if there are still tickets available on the day. If both tickets are taken on that day, I have a text label below the date to indicate that the date is unavailable. See text in red in screenshot.

j_y_0-1631186836430.png

 

My question is, how should I go about creating the formula? My current formula below doesn’t work:

If(DataCardValue22.SelectedDate) = Filter(SharepointList,DateofVisit=DataCardValue22.SelectedDate And Status = "Reserved"),"Date is unavailable.","")

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
JR-BejeweledOne
Super User
Super User

It looks like you have an extra quotation mark at the end of your formula.   Also you can just have ""   to indicate no text.  It's not necessary to put a character like a comma in there.

 

If removing the comma doesn't work, you might want to check and make sure it's comparing the dates property.  You can do that by dropping a label and datepicker on your screen with this formula: to see if it returns a number.  Use the date picker to select a date that you know is in the list.

 

CountRows(
Filter(SharePointList, DateofVisit = DatePicker.Selected.Date && Status = "Reserved"))

 

If that works, then try this

If(
   CountRows(
     Filter(SharePointList, DateofVisit = DataCardValue22.SelectedDate && Status = "Reserved")) = 2,
    "Date is unavailable". ""
)

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

View solution in original post

4 REPLIES 4
Nogueira1306
Super User
Super User

We will use a count rows. If 

If(CountRows(Filter(SPLIST, ,DateofVisit=DataCardValue22.SelectedDate, Status = "WE HAVE TICKETS")) <= 0, "Date is unavailable","")

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

 

PG_WorXz10
Community Champion
Community Champion

Hi @Anonymous ,

 

May be something like below will work in your case ? 

If(CountRows(Filter(SharepointList,DateofVisit=DataCardValue22.SelectedDate And Status = "Reserved").ID)>=2,"Date is unavailable.","")

 

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.

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

JR-BejeweledOne
Super User
Super User

It looks like you have an extra quotation mark at the end of your formula.   Also you can just have ""   to indicate no text.  It's not necessary to put a character like a comma in there.

 

If removing the comma doesn't work, you might want to check and make sure it's comparing the dates property.  You can do that by dropping a label and datepicker on your screen with this formula: to see if it returns a number.  Use the date picker to select a date that you know is in the list.

 

CountRows(
Filter(SharePointList, DateofVisit = DatePicker.Selected.Date && Status = "Reserved"))

 

If that works, then try this

If(
   CountRows(
     Filter(SharePointList, DateofVisit = DataCardValue22.SelectedDate && Status = "Reserved")) = 2,
    "Date is unavailable". ""
)

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
v-qiaqi-msft
Community Support
Community Support

Hi @Anonymous,

Have you solved your problem?

Do you want to check if there are 2 tickets reserved for the same selected date?

Could you please tell me more about your scenario?

There is something syntax wrong with your formula, DataCardValue22.SelectedDate is a type of date value, but the Filter result is a type of table. Beside, if you want to compare the date with the Filter result, you should call the DateofVisit column from the Filter() result.

In a word, other users replied with different methods which are completely correct.

Just check for only one tip, if your Status is a Choice column, please refer to it using "Status.Value".

If(CountRows(Filter(SharepointList,DateofVisit=DataCardValue22.SelectedDate And Status.Value = "Reserved"))>=2,"Date is unavailable.","")

 

Best Regards,
Qi

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,010)