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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Calculate gallery valu...
Power Apps
Answered

Calculate gallery values based on a toggle button

(0) ShareShare
ReportReport
Posted on by 70

I have 1 Gallery where i keep all my hire dates = GalHires

 

In my OnStart in the app i have a collection where I ClearCollect al my gallery values. Collection name colHires

 

I sort the Gallery 

SortByColumns(colHires,"HiredFrom",SortOrder.Ascending)

 

On the Gallery itself I have a toggle that keeps track if it is a StateDepartment job or not. A boolean.


I have a label that calculates the anniversary dates in the gallery but here is where im stuck. My calculations are complete wonky atm. label name = AnniversaryDate

 

I think that i need some more logic that can track my entire gallery and figure out if i have 1 or more bool values that are true.

 

I just cant figure out how to do this. 


The only thing i have done is: AnniversaryDate label "Visible" property is set to 

Toggle1.Value = true

This is where things get "funky". When i have more than 1 hire i can set the bool value on 1 or more to true and the label shoes me wrong dates.

Do i need a ForAll here and what would i have to do more to fi my wrong calculations?

 

 

 

 

Categories:
I have the same question (0)
  • WiZey Profile Picture
    3,023 Moderator on at

    Hello @Push ,

     

    It depends on what is your actual issue.

     

    If you want to show all records with a boolean column equal to TRUE, you can use "Filter()":

     

    Filter(
     datasource,
     boolean-column
    )

     

    If you think your calculation is wrong, I can only tell if you show us how you calculate your date.

     

  • VintagePush Profile Picture
    76 on at

    This is inside my Label  "Text" Property:
    The label shows me the correct anniversary date that is dependent on my gallery.

    With(
     {
     locColHires: Filter(GalHires.AllItems,Toggle1.Value=true)
     },
    
    With(
     {
     locDays: Mod(Sum(locColHires,Days),30),
     locMonth: Sum(locColHires, Months )+ RoundDown(Sum(locColHires, Days)/30,0)
     },
    
     
     
    "Anniversary Date: " & "01" & Text(DateAdd(DateAdd(DateAdd(NewHireDato.Value, -RoundDown((Sum(locColHires,Years)*12 + locMonth)/12,0), TimeUnit.Years), -Mod(locMonth,12), TimeUnit.Months), -locDays, TimeUnit.Days), "/mm/yyyy")
    
    )
    
    )
    
    
    
    
    
    
    


    Inside the gallery every line is a different hire period (basically a different place of work)

    it is only the items that are marked with a "StateDepartment"  (Toggle1 ) that I have to calculate for. Rest of the hire periods are irrelevant.


  • Verified answer
    WiZey Profile Picture
    3,023 Moderator on at

    If your "StateDepartment" is a boolean-type column, you can use "If()" to decide to calculate or not:

     

    If(
     ThisItem.StateDepartement,
     //Do the calculation...
    )
  • Push Profile Picture
    70 on at

    Thanks for giving me an idea!! 😁

    What I ended up with on my  calculation labels "Visible" property is 

    LookUp(colHires,StateDepartment=true).StatateDepartment

     

    Seems that this did the trick. Paired with the other calculations I already had.

    Now I can have more than 1 hire and the calculations work with the toggle.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard