cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

Collection: Outcome values 0

I want to execute a DateDiff function in a collection. The calculation is also successful, but I don't succeed in displaying it correctly in a DataTable or Gallery. Although the correct value (e.g. 5) is displayed in the code, a 0 is displayed in the gallery.

 

Patch(
    CollectionName;
    Last(CollectionName);
    {
        Hours: DateDiff(
            Last(CollectionName).Start;
            Last(CollectionName).End;
            Hours
        )
    }
)

In the meantime I have tried out some possibilities and even deleted the collection and completely rebuilt it, but I just don't know where the problem is. Maybe someone has an idea and can help me.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Collection: Outcome values 0

@brimstone 

Very nice screenshot, thank you! 

 

Your goal is to calculate the hours between ArbeitsBeginn and ArbeitsEnde.  The problem is you are changing the value of ArbeitsEnde in the same PATCH as when StundenNetto is calculated.  ArbietsEnds does not update until the entire PATCH is completed.  Because of this StundenNetto will be the result of DateDiff(18.10.2019 13:39,18.10.2019 13:39,Hours)

 

The solution is to PATCH twice instead: first update ArbeitsEnde and then update StundenNetto 

 

Patch(
    ArbeitszeitErfassung;
    Last(ArbeitszeitErfassung);
    {ArbeitsEnde: DateAdd(Now();5;Hours)}
);
Patch(
    ArbeitszeitErfassung;
    Last(ArbeitszeitErfassung);
    {
        StundenNetto: DateDiff(
            Last(ArbeitszeitErfassung).ArbeitsBeginn;
            Last(ArbeitszeitErfassung).ArbeitsEnde;
            Hours
        )
    }
);

 

Please make sure to double-check my snytax for the placement of brackets and semi-colons Cat Wink

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

8 REPLIES 8
Highlighted
Super User
Super User

Re: Collection: Outcome values 0

@brimstone 

Can you please post some screenshots of the successful outcome (e.g. showing 5) and the unsuccessful outcome (e.g. showing 0)?  This will help my understanding of your issue.

 

It would also be helpful to see your inputs (e.g. last row of collection in the viewer)

Highlighted
Advocate I
Advocate I

Re: Collection: Outcome values 0

@mdevaney 

I have set End to be 5 hours in the future (and thus the result of the DateDiff function is 5). In the Gallery the result should be in the column "Stunden", where currently 0 is displayed.


 


Highlighted
Super User
Super User

Re: Collection: Outcome values 0

@brimstone 

Very nice screenshot, thank you! 

 

Your goal is to calculate the hours between ArbeitsBeginn and ArbeitsEnde.  The problem is you are changing the value of ArbeitsEnde in the same PATCH as when StundenNetto is calculated.  ArbietsEnds does not update until the entire PATCH is completed.  Because of this StundenNetto will be the result of DateDiff(18.10.2019 13:39,18.10.2019 13:39,Hours)

 

The solution is to PATCH twice instead: first update ArbeitsEnde and then update StundenNetto 

 

Patch(
    ArbeitszeitErfassung;
    Last(ArbeitszeitErfassung);
    {ArbeitsEnde: DateAdd(Now();5;Hours)}
);
Patch(
    ArbeitszeitErfassung;
    Last(ArbeitszeitErfassung);
    {
        StundenNetto: DateDiff(
            Last(ArbeitszeitErfassung).ArbeitsBeginn;
            Last(ArbeitszeitErfassung).ArbeitsEnde;
            Hours
        )
    }
);

 

Please make sure to double-check my snytax for the placement of brackets and semi-colons Cat Wink

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

Highlighted
Advocate I
Advocate I

Re: Collection: Outcome values 0

 @mdevaney 

This works perfectly, thank you very much!

Highlighted
Super User
Super User

Re: Collection: Outcome values 0

@brimstone 

No problem at all.  By the way, what language is that collection using?  I only speak English so I was not able to understand it fully.

Highlighted
Advocate I
Advocate I

Re: Collection: Outcome values 0

@mdevaney 

 

It's german 🙂 

Highlighted
Super User
Super User

Re: Collection: Outcome values 0

@brimstone 

I was hoping it was German!  My ancestry is part German and I think it would be pretty neat to learn the language some day.

Highlighted
Advocate I
Advocate I

Re: Collection: Outcome values 0

@mdevaney 

I can fully understand your drive to learn German because of that.

I get to hear more often that the language isn't very easy to learn, but I wish you a lot of fun learning it!

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020 Winner Announced

Check it out!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (12,121)