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 / Sum Time (as Text) Dif...
Power Apps
Answered

Sum Time (as Text) Difference between Two DataCards and Display Results in Another DataCard

(0) ShareShare
ReportReport
Posted on by 5,331 Moderator

I have Form1.

In Form1 are two sets of Dropdrown the allow the user to chose form hardcoded (e.a. - 01:00, 01:15, 01:30), time options.

I need to total the number of hours worked between DataCaredValue1 and DataCardValue2, also DataCardValue3 and DataCardValue4.

I then need to Sum the total of both.

I currently have the following formula in the first 'Total Hours' label, but it is only showing '0' -
     Text(Time_In_1_DataCadValue_Dropdown.Selected.Value + Time_Out_1_DataCadValue_Dropdown.Selected.Value)

Phineas_0-1700976021007.png


Each 'Time' Dropdown has the following in the Items property -

Phineas_1-1700976601603.png

 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    @Phineas ,

    You have created yourself a bit of a monster there, it is possible as below

    With(
     {
     _Time1: 
     Value(
     First(
     Split(
     DataCardValue1.Selected.Value,
     ":"
     )
     ).Value
     ) + 
     Value(
     Last(
     Split(
     DataCardValue1.Selected.Value,
     ":"
     )
     ).Value / 60
     ),
     _Time2: 
     Value(
     First(
     Split(
     DataCardValue2.Selected.Value,
     ":"
     )
     ).Value
     ) + 
     Value(
     Last(
     Split(
     DataCardValue2.Selected.Value,
     ":"
     )
     ).Value / 60
     )
     },
     With(
     {
     _Hours: 
     RoundDown(
     _Time2 - _Time1,
     0
     )
     },
     Text(_Hours) & 
     ":" & 
     Text(
     Mod(
     (_Time2 - _Time1),
     _Hours
     ) * 60,
     "00"
     )
     )
    )

    BTW - please post your code in Text - it assists in not having to re-type.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Phineas Profile Picture
    5,331 Moderator on at

    Edited Reply -

    Which is why we are grateful for 'Monster Stompers' like you!😂

    I am interpreting your formula as a final total calculator, as it 'Totals' ALL the hours, yes?

    How do I break it up so that I can get the total of the the first segment - total hours of 'Time In 1' and 'Time Out 1' into the 'Time 1 Total',

    The second segment - total hours of 'Time In 2' and 'Time Out 2' into the 'Time 2 Total'.

    The final - Total hours of 'Time 1 Total' + 'Time 2 Total' into 'Total Hours'?

    I'm trying to modify your formula to focuse on the segments individually.

    Here is my attempt at segment one - Time_In_1 / Time_Out_1 total. I don't get any error, though all I do get is '0:00'.

    What am I missing?

    With(
         {
          _Time_In_1:
                Value(
         First(
                Split(
                        Time_In_1_DataCadValue_Dropdown.Selected.Value,
                ":"
             )
             ).Value
            / 60
    ),

         _Time_Out_1:
               Value(
                        First(
                              Split(
                        Time_Out_1_DataCadValue_Dropdown.Selected.Value,
                        ":"
                 )
                ).Value
                / 60
    )
    },
    With(
           {
             _Hours:
                    RoundDown(
                   _Time_Out_1 - _Time_In_1,
                   0
             )
    },
                 Text(_Hours) &
                  ":" &
                         Text( 
                            Mod(
                            (_Time_Out_1 - _Time_In_1),
                            _Hours
                    ) * 60,
                    "00"
            )
    )
    )

    Phineas_2-1701019323517.png

     

  • Verified answer
    WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    @Phineas ,

    The whole code I posted is only the first one (as below) - you need to modify the control names for the second one. It would be very useful for you to take a moment to understand the code (you have been posting for a long time here) so you can replicate it for anything similar on the future

    With(
     {
     _Time_In_1: 
     Value(
     First(
     Split(
     Time_In_1_DataCadValue_Dropdown.Selected.Value,
     ":"
     )
     ).Value
     ) + 
     Value(
     Last(
     Split(
     Time_In_1_DataCadValue_Dropdown.Selected.Value,
     ":"
     )
     ).Value / 60
     ),
     _Time_Out_1: 
     Value(
     First(
     Split(
     Time_Out_1_DataCadValue_Dropdown.Selected.Value,
     ":"
     )
     ).Value
     ) + 
     Value(
     Last(
     Split(
     Time_Out_1_DataCadValue_Dropdown.Selected.Value,
     ":"
     )
     ).Value / 60
     )
     },
     With(
     {
     _Hours: 
     RoundDown(
     _Time_Out_1 - _Time_In_1,
     0
     )
     },
     Text(_Hours) & 
     ":" & 
     Text(
     Mod(
     (_Time_Out_1 - _Time_In_1),
     _Hours
     ) * 60,
     "00"
     )
     )
    )

     

  • Phineas Profile Picture
    5,331 Moderator on at

    You presume too much, sir.

    I mulled over your code all morning, working through it, deconstructing it, trying to understand and rebuild it, as shown in the attempt I posted back.

    Please don't assume this is a onesided effort for which I am taking some advantage.

    My goal is to not need this form, however some of us require a bit more time and assistance in understanding the many facets of Power Apps codings, formulas, and expressions.

    As always, thank you for your input - even the acidic ones.😂

  • Verified answer
    WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    @Phineas ,

    My responses are never meant to be acidic - quite the contrary. I do however like to see that my guidance to longer-term poster such as yourself results in a learning/development experience and my apologies if some light encouragement in this direction offends (as you noted this is a partnership). What I was going to point out is that is that if you change the Items to something like this

    Table(
     {Time: "0:00", Value: 0},
     {Time: "0:15", Value: 0.25},
     {Time: "0:30", Value: 0.5},
     {Time: "0:45", Value: 0.75},
     {Time: "1:00", Value: 1},
     {Time: "1:15", Value: 1.25},
     . . . . . . .
    )
    

    You would show the Time field in the drop-down and the difference in pure hours/minutes would simply be

    Time_Out_1_DataCadValue_Dropdown.Selected.Value - Time_In_1_DataCadValue_Dropdown.Selected.Value

    and formatted as hh:mm to 

    With(
     {
     _Hours: 
     RoundDown(
     Time_Out_1_DataCadValue_Dropdown.Selected.Value - Time_In_1_DataCadValue_Dropdown.Selected.Value,
     0
     )
     },
     Text(_Hours) & 
     ":" & 
     Text(
     Mod(
     (Time_Out_1_DataCadValue_Dropdown.Selected.Value - Time_In_1_DataCadValue_Dropdown.Selected.Value),
     _Hours
     ) * 60,
     "00"
     )
    )

     

  • Phineas Profile Picture
    5,331 Moderator on at

    No apology necessary. Just wanted to clarify that I spend hours trying to comprehend and understand how all this works, and do grately appreciate the expert input and assistance from Super Users such as yourself.

    Not even sure, other than longevity, why I have 'Resident Rockstar' anywhere near my name.🤣

    I'll file away your second suggestion. But, I like how the existing turned out. I think I'll keep it that way.

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 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard