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.
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!
Solved! Go to Solution.
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". ""
)
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)!
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.
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". ""
)
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.","")
User | Count |
---|---|
252 | |
101 | |
94 | |
47 | |
38 |