cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PPSA
Resolver II
Resolver II

Gallery date filter/ add days / don't include weekends

Hi all,

I've just started a new app and need some help please.

I have a screen showing incoming deliveries by today, tomorrow, the next, its a gallery and a nested gallery within that.

The main gallery is filtered by this - Filter(GroupBy(Containerinfo,"Contnr_booked","data"),Contnr_booked<=DateAdd(Today(),2,Days))

PPSA_0-1595859882646.png


My problem will be on Thursdays/ Fridays the tomorrow and next will be blank as no deliveries get scheduled for weekends.

Is there a way to say if the tomorrow or next is a saturday or sunday then go to the next working day?

Thanks!




1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @PPSA ,

 

Do you mean you want to filter out the records for the next three days (except the weekend)?

You can try to use this code to calculate date without Weekends.

DateAdd(
    Now(),
    DaysAdd.Text + 2 * If(//test
        (Weekday(
            Now(),
            StartOfWeek.Monday
        ) + DaysAdd.Text) > 5,
        RoundDown(
            (DaysAdd.Text - (5-Weekday(//ass
                Now(),
                StartOfWeek.Monday
            ))) / 5,
            0
        ) + 1
    )
)

Then modify the Gallery.Items property as follows.

Filter(
GroupBy(Containerinfo,"Contnr_booked","data"),
Text(Contnr_booked,DateTimeFormat.ShortDate)=Text(Today(),DateTimeFormat.ShortDate), //Today's items

Text(Contnr_booked,DateTimeFormat.ShortDate)= Text(DateAdd(Now(),1+2*If((Weekday(Now(),StartOfWeek.Monday)+1)>5,RoundDown((1-(5-Weekday(Now(),StartOfWeek.Monday)))/5,0)+1)),DateTimeFormat.ShortDate), //Tomorrow's items

Text(Contnr_booked,DateTimeFormat.ShortDate)= Text(DateAdd(Now(),2+2*If((Weekday(Now(),StartOfWeek.Monday)+2)>5,RoundDown((2-(5-Weekday(Now(),StartOfWeek.Monday)))/5,0)+1)),DateTimeFormat.ShortDate), //The next's items
)

 

Hope this helps.

Sik 

View solution in original post

10 REPLIES 10
cds
Impactful Individual
Impactful Individual

you can get the name of the day with Text(Date, "dddd")

PPSA
Resolver II
Resolver II

Hi, @cds , thanks, this wasn't actually what I need though.

My gallery shows 3 days worth of deliveries

today, today +1, today+2

I don't want my today +1 or +2 to be blank because there are no deliveries on a weekend. (This scenario would only happen on Thursday and Friday)

I'd like it to go to the next working day(s), Monday/Tuesday

cds
Impactful Individual
Impactful Individual

switch tomorrow startswith "sat", +2, "sun" +1

nextday = tomorrow +1

PPSA
Resolver II
Resolver II

Sorry @cds , it may just be me but I'm not following here,

My gallery is filtered with this currently

Filter(
GroupBy(
Containerinfo,
"Contnr_booked",
"data"
),
Contnr_booked <= DateAdd(
Today(),
2,
Days
)
)

I'm not sure where I'd put what you are suggesting at all.

cds
Impactful Individual
Impactful Individual

Filter(
GroupBy(
Containerinfo,
"Contnr_booked",
"data"
),
Contnr_booked <= DateAdd(
Today(),
Switch(Text(Today(), "dddd"),
"Friday", 3

"Saturday", 2

 1),
Days
)
)

 

Then on day after gallery:

Filter(
GroupBy(
Containerinfo,
"Contnr_booked",
"data"
),
Contnr_booked <= DateAdd(
Today(),
Switch(Text(Today(), "dddd"),
"Friday", 4

"Saturday", 3

 2),
Days
)
)

 

Plz kudo me posts if this works 😃

PPSA
Resolver II
Resolver II

Ah, now I'm with you @cds .

Unfortunately it is all withing one gallery, well two, so I don't believe this solution will work.

It is a gallery showing the 3 days, then nested within that a gallery with the grouped data for each day.

cds
Impactful Individual
Impactful Individual

i think the concept should still work you might have to adapt it to the nested gal?

v-siky-msft
Community Support
Community Support

Hi @PPSA ,

 

Do you mean you want to filter out the records for the next three days (except the weekend)?

You can try to use this code to calculate date without Weekends.

DateAdd(
    Now(),
    DaysAdd.Text + 2 * If(//test
        (Weekday(
            Now(),
            StartOfWeek.Monday
        ) + DaysAdd.Text) > 5,
        RoundDown(
            (DaysAdd.Text - (5-Weekday(//ass
                Now(),
                StartOfWeek.Monday
            ))) / 5,
            0
        ) + 1
    )
)

Then modify the Gallery.Items property as follows.

Filter(
GroupBy(Containerinfo,"Contnr_booked","data"),
Text(Contnr_booked,DateTimeFormat.ShortDate)=Text(Today(),DateTimeFormat.ShortDate), //Today's items

Text(Contnr_booked,DateTimeFormat.ShortDate)= Text(DateAdd(Now(),1+2*If((Weekday(Now(),StartOfWeek.Monday)+1)>5,RoundDown((1-(5-Weekday(Now(),StartOfWeek.Monday)))/5,0)+1)),DateTimeFormat.ShortDate), //Tomorrow's items

Text(Contnr_booked,DateTimeFormat.ShortDate)= Text(DateAdd(Now(),2+2*If((Weekday(Now(),StartOfWeek.Monday)+2)>5,RoundDown((2-(5-Weekday(Now(),StartOfWeek.Monday)))/5,0)+1)),DateTimeFormat.ShortDate), //The next's items
)

 

Hope this helps.

Sik 

Almost @v-siky-msft, I really should have taken more care to explain I think,

 

Not to filter out the next 3 days, to filter my collection down to only 3 days excluding weekends. 

 

I'll see if I can get your suggestion working as soon as I start this morning, thank you. 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,611)