Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Default item in gallery with date items

(1) ShareShare
ReportReport
Posted on by 15
Hello community,
 
I have a gallery with the following items (weekdays of one week) where the input of "lbl_Monday_Hidden.Text" comes from a calendar week selection and contains the monday of the selected calender week.
ForAll(
    Sequence(
        5;
        0;
        1
    );
    {
        datum: DateAdd(
            lbl_Monday_Hidden.Text;
            Value;
            TimeUnit.Days
        )
    }
)
The gallery itself works as expected but I am not able to set the default property to the current date.
I tried different methods, from Today(), DateTime(Year(Today()); Month(Today());Day(Today());0;0;0), Text(Today(); "dd.mm.yyyy hh:mm:ss") but could not get it working,
 
Does anyone have an idea?
 
Thanks and kind regards
Joseph
 
Categories:
  • Verified answer
    JS_PA Profile Picture
    15 on at
    Default item in gallery with date items
    Thanks for the response.
     
    I ended up by setting the today indicator circle to visible if
    ThisItem.datum = gblSelected
    where in OnVisible of the screen gblSelected is defined as
    Set(
        gblSelected;
        Today()
    )
    This results in:
     
    Before this implementation I tried to show the circle with "ThisItem.IsSelected".
  • D_D Profile Picture
    107 on at
    Default item in gallery with date items

    I think I completly missed the point before. So what you are looking for is a default value for the Gallery?
    The Items of the Gallery are of Type

    {datum: Date}

    So a default Value for the Gallery could be

    {datum: Today()}

     
  • JS_PA Profile Picture
    15 on at
    Default item in gallery with date items
    Thank you.
    The items themselves worked before - but the default item is still the problem, as it says that it is not an element of the items, even though the items are of type date...
  • Suggested answer
    D_D Profile Picture
    107 on at
    Default item in gallery with date items
    Ok, for me it worked when the value from lbl_Monday_Hidden.Text is stored in a variable and then use the variable in your formula. For dynamically changes you always have to use valiables instead of values of control elements.
    ForAll(
        Sequence(
            5;
            0;
            1
        );
        {
            datum: DateAdd(
                variableNameHere;
                Value;
                TimeUnit.Days
            )
        }
    )
    --------------------------------------------------------------------------------------
    If this helps you or solved your question, please like or mark this as an answer.
    Best regards, David
  • JS_PA Profile Picture
    15 on at
    Default item in gallery with date items
    Hi D_D,
     
    thanks for the quick reply.
    When I open the app the current date in the gallery should already be preselected - therefore I wanted to add Today() in the Default property.

    lbl_Monday_Hidden.Text is of Type "Date":

     
     
  • D_D Profile Picture
    107 on at
    Default item in gallery with date items
    Hello Joseph,
     
    I did't understand what value you want to set to the current date. When I use this in a gallery I get the next five days starting from the current date.
    ForAll(
        Sequence(
            5,
            0,
            1
        ),
        {
            datum: DateAdd(
                Now(),
                Value,
                TimeUnit.Days
            )
        }
    )

    So i guess the value from lbl_Monday_Hidden.Text causes the problem. What value does lbl_Monday_Hidden.Text view when you add it as text in a label control?

    --------------------------------------------------------------------------------------
    If this helps you or solved your question, please like or mark this as an answer.
    Best regards, David

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard