Hi,
I need help to understand why my IF doesn't work in this formula.
I have two dates From and To, these dates are selectable:
Name: DatePickerSelectableDateFrom and DatePickerSelectableDateTo
I also have SharepointList where is date From (upper date) and To (lower date), and those dates are defined by the user
Name:
DatePickerGalleryCheckboxFrom (upper date)
DatePickerGalleryCheckboxTo (lowerdate)
I want to disable that gallery checkbox by adding a formula IF selectable dates are between DatePickerSelectableDateFrom and DatePickerSelectableDateTo
So if we have the 27th of June picked as the DatePickerSelectableDateFrom and the 28th of June as the DatePickerSelectableDateTo the Desk 13, 15, and 18 should be disabled and others of them should be enabled.
I already tried:
If(DatePickerSelectableDateFrom.SelectedDate <= DatePickerGalleryCheckboxFrom.SelectedDate ||DatePickerSelectableDateTo.SelectedDate.SelectedDate <= DatePickerGalleryCheckboxTo.SelectedDate , DisplayMode.Disabled, DisplayMode.Edit)
but it is not working as expected any help with that maybe I should add And not the Or I started to feel confused in here.
Thanks
Solved! Go to Solution.
Hi @SevenWishes ,
I think you need this
If(
(
DatePickerSelectableDateFrom.SelectedDate >= DatePickerGalleryCheckboxFrom.SelectedDate &&
DatePickerSelectableDateFrom.SelectedDate.SelectedDate <= DatePickerGalleryCheckboxTo.SelectedDate
) ||
(
DatePickerSelectableDateTo.SelectedDate.SelectedDate >= DatePickerGalleryCheckboxFrom.SelectedDate &&
DatePickerSelectableDateTo.SelectedDate.SelectedDate <= DatePickerGalleryCheckboxTo.SelectedDate
),
DisplayMode.Disabled,
DisplayMode.Edit
)
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.
Visit my blog Practical Power Apps
Hi,
Could you insert 4 labels and tell me what is return for:
DatePickerSelectableDateFrom.SelectedDate
DatePickerGalleryCheckboxFrom.SelectedDate
DatePickerSelectableDateTo.SelectedDate.SelectedDate
DatePickerGalleryCheckboxTo.SelectedDate
Hi,
Sure.
Thanks for the answer.
By following my example I added all labels to a Gallery and have the correct numbers:
DatePickerSelectableDateFrom: 27/06/2022
DatePickerSelectableDateTo: 28/06/2022
Now it depends on the item in Sharepoint List:
Desk 13:
DatePickerGalleryCheckboxFrom : 27/06/2022
DatePickerGalleryCheckboxTo: 27/06/2022
Desk17
DatePickerGalleryCheckboxFrom: 29/06/2022
DatePickerGalleryCheckboxTo: 01/07/2022
Desk18
DatePickerGalleryCheckboxFrom: 27/06/2022
DatePickerGalleryCheckboxTo: 28/06/2022
etc
I hope this helps.
Thank you
With no formatting in the labels, like Text(Somedate, "dd/mm/yyy") ?
Hi,
Not sure I understand what is that for,
So basically the date on the first screenshot the top and lower ones where are desks are datepicker they are not labels, but when added a Label here it is:
and results:
the date is the same as on DatePickerSelectableDateFrom from the first picture.
Regarding dates from Gallery I used LookUp function as they have their own dates in Sharepoint File
DatePickerGalleryCheckboxFrom:
LookUp('Desk Reservation', DeskText = ThisItem.Title,'Check Out From')
DatePickerGalleryCheckboxTo
LookUp('Desk Reservation', DeskText = ThisItem.Title,'Check Out To')
The code I looking for regarding Gallery Checkboxes is something similar to this:
DisplayMode:
If(DatePickerSelectableDateFrom.SelectedDate = DatePickerGalleryCheckboxFrom.SelectedDate ||
DatePickerSelectableDateFrom.SelectedDate = DatePickerGalleryCheckboxTo.SelectedDate ||
DatePickerSelectableDateTo.SelectedDate = DatePickerGalleryCheckboxFrom.SelectedDate ||
DatePickerSelectableDateTo.SelectedDate = DatePickerGalleryCheckboxTo.SelectedDate,
DisplayMode.Disabled, DisplayMode.Edit
)
but this one only disables the date if the SelectableDate is equal to GalleryDate but not between as < or > isn't working correctly or I cannot use it in the right way.
Hi,
I am havinh troubel getting the logic you are trying to implement. Maybe a scenario will help.
Is this an app for sheduling Desk? If so don't you just need to check if your starting date is greater than the desk's upper occupation date?
I have built an example and I have put it in rthe Text property just to make it easier to read. Please see if I am anywhere near what you are trying to do.
Thanks,
It is very easy to understand.
We have two scenarios:
1. User is booking a desk then providing details which desk is taking and on what dates
lets pick the same date as we did on the first post 27 June to 28 June and Desk number 13
2. After a while other user want to book the same desk first he is trying to pick the same dates, at the message 5 at the end I typed my code to review, so when he is picking up 27 to 28 of June the desk is occupied by someone else, so he is typing again and changing dates 27 of June to 29 June, still occupied. then he is changing the date From to 26 to 29 and it is available.
I hope it has more sense, not sure what else I can provide than the code I already added.
Thank you for your example and time but it is not working as it is giving me this:
I used the same scenario as you did.
Date "From " and the latest date in the Gallery, the results seem to be a weird one as it is disabling the desks even after the 28 of June which is wrong, Desk 14, 16, and 17 shouldn't be disabled as per the dates in the checkboxes the Desk 14 was occupied between 30 June to 1 July, Desk 16 - 29 June to 30 June and Desk 17 - 29 June to 1 July.
You say "changing the date From to 26 to 29 and it is available. "
Does this mean that the user wants to book the desk from the 26th through till the 29th or does this mean he wants any of the dates in range, so either the 26th, the 27th, the 28th or the 29th?
In the first case, the desk is not available because someone has it for the 27th and the 28th, right?
In the second scenario, the desk is available on the 26th, occupied on the 27th and 28th and then available again on the 29th.
Wich one is it?
I did that desks a little bit larger. This is a gallery all items are placed in Sharepoint List, gallery has DeskName, From, and To dates as we have here on the screen. This data can be patched to Sharepoint List by any user the user needs to pick the date he wants to book the desk.
Imagine I am a user who wants to Pick Desk 17 between 29 June and 01 July and you are the next person who wants to pick Desk 17 on 30 June only. That desk will be available for you as I have no clue how to make it disable as the desk 17 have two dates 29th and 1 July, I would have to create a variable or code to say that between these two dates there is one more date which is 30 June that is not available for use. But for that, I do not have enough knowledge of how to do this.
Btw I created a collection for that, it is giving me a correct list of dates between StartDate and EndDate, if I type
25th July and enddate 30July it will count all data between it, I only need to add this to Checkbox Gallery as it needs to be equal to this one then if the DatePicker will be equal to checkbox in the gallery all the dates will be correctly disabled.
Set(var1stDate,DatePickerSelectableDateFrom.SelectedDate);
Set(var2stDate,DatePickerSelectableDateTo.SelectedDate);
Set(varDifference, DateDiff(var1stDate, var2stDate, Days));
Clear(CollectionDateDiff);
ForAll(Sequence(varDifference +1), Collect(CollectionDateDiff, {Dates: DateAdd(var1stDate,CountRows(CollectionDateDiff),Days)}));
@SevenWishes I think you may have to take a step back and look at hoe your data is structure and also collect some ideas from the community.
Take a look at this amazing video from @RezaDorrani : Top 10 Power Apps Examples (Showcase) - YouTube
User | Count |
---|---|
252 | |
106 | |
96 | |
50 | |
39 |