1. You can create reusable to convert ticks to days, hours, and minutes. You can encapsulate your formula in a reusable Power Apps function using the With() statement
With(
{
TotalDays: RoundDown(varNoTicks / 864000000000, 0),
RemainingTicksAfterDays: Mod(varNoTicks, 864000000000),
TotalHours: RoundDown(RemainingTicksAfterDays / 36000000000, 0),
RemainingTicksAfterHours: Mod(RemainingTicksAfterDays, 36000000000),
TotalMinutes: RoundDown(RemainingTicksAfterHours / 600000000, 0)
},
If(
TotalDays > 0,
TotalDays & " days " & TotalHours & " hours " & TotalMinutes & " minutes",
If(
TotalHours > 0,
TotalHours & " hours " & TotalMinutes & " minutes",
TotalMinutes & " minutes"
)
)
)
Replace varNoTicks with your input parameter or variable name containing ticks, use this function as part of your gallery items formula for duration labels.
2. To calculate the duration for the current status dynamically in the gallery, remove the white spaces from the status using Substitute(ThisItem.CurrentStatus, " ", ""). For calculating the time difference between the current date and a previous version’s modified date, use
With(
{
TicksDifference: DateDiff(ThisItem.PrevoiuseVersionModified, Now(), Milliseconds) * 10000
},
With(
{
TotalDays: RoundDown(TicksDifference / 864000000000, 0),
RemainingTicksAfterDays: Mod(TicksDifference, 864000000000),
TotalHours: RoundDown(RemainingTicksAfterDays / 36000000000, 0),
RemainingTicksAfterHours: Mod(RemainingTicksAfterDays, 36000000000),
TotalMinutes: RoundDown(RemainingTicksAfterHours / 600000000, 0)
},
If(
TotalDays > 0,
TotalDays & " days " & TotalHours & " hours " & TotalMinutes & " minutes",
If(
TotalHours > 0,
TotalHours & " hours " & TotalMinutes & " minutes",
TotalMinutes & " minutes"
)
)
)
)
Use these formulas in your gallery labels to show durations for each stage. Replace the variable names and fields (varNoTicks, PrevoiuseVersionModified) with your actual data source fields or variables. This will format the durations and dynamically compute the current status duration