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 / Calculating Date based...
Power Apps
Answered

Calculating Date based on Selected Result in Gallery with Checkboxes

(0) ShareShare
ReportReport
Posted on by 23

Hello Power Apps Community,

I'm encountering an issue in my Power Apps application and I would like to seek your assistance in finding a solution.

I have a scenario where I need to select a Result from a gallery with checkboxes, and based on the selected Result, calculate a corresponding date using a date picker field.

Previously, I was using a combo box to select the Result, and the date picker would calculate the date based on the selected Result. However, now the Result options are presented within a gallery, which also contains checkboxes for selection. The challenge I'm facing is how to deal with this new selection approach. I need that, when selecting an option in the gallery using the corresponding checkbox, some actions are performed:

The date must be calculated based on the selected Resultado (Deadline).
Here is the actual code I am using for the date calculation in the date picker field (DefaultDate):

 

If(
 LookUp(ParametroAtosJudiciais;
 PrazoDecorrenteAto = cmbAdvogadoRedatorVisualizacaoProcesso_5.Selected.Value;
 aux
 ) <> 1 && LookUp(
 DiasUteis;
 Data >= dtDataPublicacaoVisualizacaoProcesso.SelectedDate
 ).DiaUtil = "Sim";
 Last(FirstN(Filter(DiasUteis;
 Data >= dtDataPublicacaoVisualizacaoProcesso.SelectedDate;
 DiaUtil = "Sim"
 ); LookUp(
 ParametroAtosJudiciais;
 PrazoDecorrenteAto = cmbAdvogadoRedatorVisualizacaoProcesso_5.Selected.Value
 ).DiasUteis +1)).Data
)

 

 

Categories:
I have the same question (0)
  • Verified answer
    Sundeep_Malik Profile Picture
    6,501 on at

    Hey @marizilla_99 

     

    To handle the new selection approach using checkboxes in the gallery, you can modify the code to calculate the date based on the selected Result using the checkbox.

     

    First, make sure you have a collection to store the selected Result from the gallery. You can create a collection using the ClearCollect function when the checkbox is selected in the gallery.

    ClearCollect(SelectedResults, ThisItem);

     

    Then, modify the date calculation formula in the date picker's DefaultDate property to use the selected Result from the collection. You can use the First function to retrieve the selected Result from the collection and calculate the date accordingly.

     

    If(
    LookUp(ParametroAtosJudiciais;
    PrazoDecorrenteAto = First(SelectedResults).Result;
    aux
    ) <> 1 && LookUp(
    DiasUteis;
    Data >= dtDataPublicacaoVisualizacaoProcesso.SelectedDate
    ).DiaUtil = "Sim";
    Last(FirstN(Filter(DiasUteis;
    Data >= dtDataPublicacaoVisualizacaoProcesso.SelectedDate;
    DiaUtil = "Sim"
    ); LookUp(
    ParametroAtosJudiciais;
    PrazoDecorrenteAto = First(SelectedResults).Result
    ).DiasUteis +1)).Data
    )

     

    I hope this helps 🙂

  • marizilla_99 Profile Picture
    23 on at

    Hello, @Sundeep_Malik 

    I wanted to express my sincere gratitude for your valuable assistance in solving my Power Apps challenge. Your solution worked perfectly, and now the date calculation based on the selected Result using checkboxes in the gallery is functioning as expected.

    Additionally, I was wondering if you have any insights on how to automatically uncheck the previously selected checkbox when a new one is checked. I tried various approaches but couldn't achieve it on my own.

    Thank you once again for your support and expertise. I greatly appreciate it!

    Best regards

  • Verified answer
    Sundeep_Malik Profile Picture
    6,501 on at

    @marizilla_99 

     

    No problem buddy, I am here to help 🙂

     

    Regarding automatically unchecking the previously selected checkbox when a new one is checked, you can achieve this by using a combination of variables and the OnChange property of the checkbox controls in the gallery.

     

    Follow the below steps:

     

    1. Create a variable to store the last selected checkbox's item from the gallery. Let's call it LastSelectedItem.

    2. Use the OnChange property of the checkbox control in the gallery to update the SelectedResult variable with the corresponding value when the checkbox is checked or unchecked. Additionally, update the LastSelectedItem variable to the current item of the checkbox control when it is checked. You can write a similar expression to below:


    If(
    ThisItem.IsSelected,
    Set(SelectedResult, ThisItem.Result); Set(LastSelectedItem, ThisItem),
    Set(SelectedResult, ""); Set(LastSelectedItem, "")
    )

    3. Now Add a condition to the OnCheck property of the checkbox control to compare the current item with the LastSelectedItem variable. If they match, the checkbox will be checked; otherwise, it will be unchecked. This will automatically uncheck the previously selected checkbox when a new one is checked.


    ThisItem = LastSelectedItem

     

    With this approach, when you check a new checkbox in the gallery, it will automatically uncheck the previously selected checkbox, ensuring that only one checkbox is selected at a time.

     

    I hope this helps 🙂

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 429 Most Valuable Professional

#2
11manish Profile Picture

11manish 191 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 122 Super User 2026 Season 2

Last 30 days Overall leaderboard