web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adding items to collec...
Power Apps
Answered

Adding items to collection based on If condition

(0) ShareShare
ReportReport
Posted on by 1,119

Hi there,

 

i want to get help on adding the below items into collection. Please assist. 

Based on the if condition, if it is future time slot, the collection should not hold that value.

 

If(TimeValue(Now())<TimeValue("5:30"), Set(varddtimeItems, "5:30 AM"),
If(TimeValue(Now())<TimeValue("8:30"), Set(varddtimeItems, "8:30 AM"),
If(TimeValue(Now())<TimeValue("18:45"), Set(varddtimeItems, "6:45 PM"),
If(TimeValue(Now())<TimeValue("21:30"), Set(varddtimeItems, "9:30 PM")))))

Categories:
  • venka91 Profile Picture
    1,119 on at

    I tried the below forumula, but it is storing only one value. 

    I am expecting, if my current time grater the pas time, the collection should hold the values of past time slots.

     

    ClearCollect(ddItem, {varddtimeItems:
    If(TimeValue(Now())>TimeValue("5:30"), "5:30 AM",
    If(TimeValue(Now())>TimeValue("8:30"), "8:30 AM",
    If(TimeValue(Now())>TimeValue("18:45"),"6:45 PM",
    If(TimeValue(Now())>TimeValue("21:30"), "9:30 PM"))))})

  • venka91 Profile Picture
    1,119 on at

    I managed to get the items of dropdown by writing the formulas directly into the Item Property of dropdown. But still, i am getting Blank space on my drop down, when the if condition fails. How to clear these whitespaces.

     

    In Item property of drop down :

     

    ["Select",(If(TimeValue(Now())>TimeValue("5:30"), "5:30 AM")),
    (If(TimeValue(Now())>TimeValue("8:30"), "8:30 AM")) ,
    (If(TimeValue(Now())>TimeValue("18:45"),"6:45 PM")) ,
    (If(TimeValue(Now())>TimeValue("21:30"), "9:30 PM"))]

     

    But this is giving blank space for the If conditions that are false.

     

    venka91_0-1640156693015.png

     

  • Verified answer
    AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    One quick solution is to change the box items to this:

    Filter(["Select",(If(TimeValue(Now())>TimeValue("5:30"), "5:30 AM")),
    (If(TimeValue(Now())>TimeValue("8:30"), "8:30 AM")) ,
    (If(TimeValue(Now())>TimeValue("18:45"),"6:45 PM")) ,
    (If(TimeValue(Now())>TimeValue("21:30"), "9:30 PM"))],!IsBlank(Value))

  • venka91 Profile Picture
    1,119 on at

    ok, I do not see the blanks now. but for the past dates also this validation pulls only past time slot.

    If it is pass date, it should show all 4 time slots. and for current date, it suppose the validate the formula i told above.

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    what is the name of the value that is the past time slot is it in a gallery so thisitem.something or is it a variable or a datepicke? i need to use it to reference the formula

  • venka91 Profile Picture
    1,119 on at

    no datas are coming from gallery.

    This is standalone drop down. Based on the datapicker, if chosen date is past, the drop down must show all the time slots, 5:30, 8:30, 6:45 and 9:30

    In case if the date is today, drop down should validate the If formula and show only the past time slots, Example, if the curernt time is 15:00, then it should show only 5:30 and 8:30 current date.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard