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 / Show Datediff into Label
Power Apps
Answered

Show Datediff into Label

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi i got a problem. I tried to show the Datediff into a Label. The problem i got is , the datediff function. I used 2 records. Both of them got the same typ of field into the table but the diffrents are the optionset.

 

For example start date is Zeiten(the Field of the table) with optionset 'Pause ende' and the end date is Zeiten with the optionset 'Pause start' i tried so mutch but i dont get a date value of this.

 

Maybe someone can help?

Categories:
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Anonymous ,

     

    I am assuming you're applying the OptionSet/Choices onto a dropdown control?

     

    If yes, try:

     

     

    DateDiff(
     DateValue(Dropdown1.SelectedText.Value),
     DateValue(Dropdown2.SelectedText.Value)
    )

     

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution

    If you like my response, please give it a Thumbs Up.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    No the optionset isnt a dropdown menu.

    The option choose is on a button click. if i clicked the button Start Arbeit then in the background my code write the date Now() on the row field Zeiten and the Optionsetvalue is 'Start Arbeit'

     

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Anonymous - there is a language difficulty for me but just to be clear, when you say "optionset", are you referring to Dataverse Choices? (formerly known as CDS Option Sets) ?

     

    Could you share screenshots of your set up so I can understand better.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Of curse i hope you understand what i mean with the screenshots. The screen with the buttons make the choose from the option set 1 button 1 option . the other screen is the option set from the Dataverse. And i wanna make a datediff between two records of them.

    option.png
    button.png
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Anonymous - so I understand this correctly, you want to get the Option Set Value based on the selected Option Label?

     

    Amik_0-1685970256826.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    No i try to use the datediff function on 2 records with different options. There is a screenshot from the second page on the app. At the top there is a Gallery with the records filtered on 2 different typ of records. At the bottom there are a label what i try to fill and then i hope i get the datediff from 2 records. this is the current code but it doesnt work : DateDiff(
    DateValue(Arbeitszeit=[@Arbeitsmodel].'Pause ende';"de" );
    DateValue(Arbeitszeit=[@Arbeitsmodel].'Pause start';"de")
    )

    label.png
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    Sorry @Anonymous it is very difficult to understand what you're trying to do. Your expresssion makes no sense, your comparing a field "Arbeitszeit" with an Option Set, and then wrapping it in a Date Value function.

     

    Could you draw what you're trying to do in Excel for example together with the expected result.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    this will be a app where i can see how long someone make a break or how long he/she worked .

    For this i have to check the times.

    I only use 2 rows for each record.

    i row is the 'Zeiten' is from type date and the other row is ArtderArbeit.

    I took a screen from the Dataverse for you.

    i try to calculate minus record 1 from record 2.

    With the result i try to fill a lable.

     

    Data.png
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Anonymous ,

    I think I understand what you’re trying to do but you’re approaching it in the wrong way. You need to use two Lookup functions to identify the date value for a each record, and then compare them with DateDiff. If there are two rows for each record per employee, I assume you have a unique identifier for those employees (e.g. employee name or employee id).

     

    If yes, you can try:

     

     

    DateDiff(
     DateValue(
     LookUp(
     'Your Table',
     'Unique ID for Employee' = "1" && ArtDerArbeits = [@Arbeitsmodel].'Pause ende'
     ).Zeiten,
     "da"
     ),
     DateValue(
     LookUp(
     'Your Table',
     'Unique ID for Employee' = "1" && ArtDerArbeits = [@Arbeitsmodel].'Pause start'
     ).Zeiten,
     "da"
     )
    )

     

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution

    If you like my response, please give it a Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I got it for only one Record. But i have to do it for an array of records.

    maybe you can help me.

    Here is the code for one record:

    Text(
    DateDiff(
    DateTimeValue(
    LookUp(
    Filter(
    Arbeitszeit;
    DateValue('Erstellt am') = DateValue(DatePicker2.SelectedDate) && ArtDerArbeitsZeit = [@Arbeitsmodel].'Pause start');
    DateValue('Erstellt am') = DatePicker2.SelectedDate && ArtDerArbeitsZeit = [@Arbeitsmodel].'Pause start').Zeiten;
    "de-DE");
    DateTimeValue(
    LookUp(
    Filter(
    Arbeitszeit;
    DateValue('Erstellt am') = DateValue(DatePicker2.SelectedDate) && ArtDerArbeitsZeit = [@Arbeitsmodel].'Pause ende');DateValue('Erstellt am') = DatePicker2.SelectedDate && ArtDerArbeitsZeit = [@Arbeitsmodel].'Pause ende'
    ).Zeiten;
    "de-DE");
    TimeUnit.Minutes )
    ) & " Minuten Pause"

     

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 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard