Hello.
I have a DateTime filed in my app with the name Downtimes and sum of all this downtimes.I want to combine same intervals with different reasons.
For example:
IT Downtime from 5:00 to 7:00 - 2 hours
Maintenance Downtime from 6:00 to 8:00 - 2 hours
Now Sum of Downtime Time is 4 hours. And I want it to be 3 hours because from 6 to 7 hour is the same interval.
How I can make it in PowerApps?
You could simply take the second date/time from the second downtime and the first date/time from the first downtime, and use DateDiff function
DateDiff( StartDateTime, EndDateTime, Hours )
In order to know if the second interval overlaps with the first interval - this may not matter. Instead, use the If function to determine if the difference is negative - if it is negative, then they do not overlap and in that case you need to take both intervals
DateDiff( StartDateTime, EndDateTime, Hours ) + DateDiff( StartDateTime, EndDateTime, Hours )
Otherwise, if they do overlap, or in other words, if the next interval's end date/time is sometime after the previous one's end date/time you just do the simple one where you take the EndDateTime of the second interval and subtract it from the StartDateTime of the first interval:
DateDiff( StartDateTime, EndDateTime, Hours )
Check if the above approach helps as a starting point.
If you want to be able to do this for any "N" number of intervals in a seamless way, you'll need to do a bit more than the above. Check if the above helps as starting point and if not, you can try to post here and I might see if I have time to check again for a more seamless solution for you.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
184 | |
45 | |
45 | |
34 | |
34 |
User | Count |
---|---|
257 | |
82 | |
78 | |
67 | |
65 |