I have 2 duration columns. On their own, the...

I have 2 duration columns.

On their own, they work fine.

If I create a virtual column and do [columnA]-[ColumnB] that works

But I copy the 2 formulas into a virtual column as:

โ€œFormula from ColumnAโ€ - โ€œFormula from ColumnBโ€

I get "โ€ฆhas inputs of an invalid type โ€˜Unknownโ€™ "

Anyone any ideas?

Formula from ColumnA =SUM(Select([Related Process][Hours],[Status]=โ€œPendingโ€))

Formula from ColumnB =CONCATENATE(FLOOR(( HOUR(SUM(Select([Related Process][Hours],[Status]=โ€œPendingโ€))-IF(โ€œ17:00:00โ€<TimeNow(),โ€œ000:00:00โ€,โ€œ17:00:00โ€-TIMENOW())) +(MINUTE(SUM(Select([Related Process][Hours],[Status]=โ€œPendingโ€))-IF(โ€œ17:00:00โ€<TimeNow(),โ€œ000:00:00โ€,โ€œ17:00:00โ€-TIMENOW()))/60) +(SECOND(SUM(Select([Related Process][Hours],[Status]=โ€œPendingโ€))-IF(โ€œ17:00:00โ€<TimeNow(),โ€œ000:00:00โ€,โ€œ17:00:00โ€-TIMENOW()))/3600))/8) *8,":00:00")

0 10 422
10 REPLIES 10

Managed to sort by removing the CONCATENATE since I presume that [Duration]+1 adds one hour.

But still odd and would like Appsheet to look at

@Aleksi_Alkio

Time handling is odd, yes.

Your expression reformatted for clarity:

SUM(

SELECT(

[Related Process][Hours],

([Status] = โ€œPendingโ€)

) ) - CONCATENATE(

FLOOR(

(

HOUR(

SUM(

SELECT(

[Related Process][Hours],

([Status] = โ€œPendingโ€)

)

)

  • IF(

(โ€œ17:00:00โ€ < TIMENOW()),

โ€œ000:00:00โ€,

(โ€œ17:00:00โ€ - TIMENOW())

)

)

  • (

MINUTE(

SUM(

SELECT(

[Related Process][Hours],

([Status] = โ€œPendingโ€)

)

)

  • IF(

(โ€œ17:00:00โ€ < TIMENOW()),

โ€œ000:00:00โ€,

(โ€œ17:00:00โ€ - TIMENOW())

)

)

/ 60

)

  • (

SECOND(

SUM(

SELECT(

[Related Process][Hours],

([Status] = โ€œPendingโ€)

)

)

  • IF(

(โ€œ17:00:00โ€ < TIMENOW()),

โ€œ000:00:00โ€,

(โ€œ17:00:00โ€ - TIMENOW())

)

)

/ 3600

)

)

/ 8

)

  • 8,

โ€œ:00:00โ€ )

Your formula performs the SUM(SELECT(โ€ฆ)) four times, which is inefficient, potentially slow, and cumbersome to maintain. I recommend you move it to a virtual column so its computed only once:

=SUM(

SELECT(

[Related Process][Hours],

([Status] = โ€œPendingโ€)

) )

Call it (e.g.) Pending Hours. Then your formula reduces to:

[Pending Hours] - CONCATENATE(

FLOOR(

(

HOUR(

[Pending Hours]

  • IF(

(โ€œ17:00:00โ€ < TIMENOW()),

โ€œ000:00:00โ€,

(โ€œ17:00:00โ€ - TIMENOW())

)

)

  • (

MINUTE(

[Pending Hours]

  • IF(

(โ€œ17:00:00โ€ < TIMENOW()),

โ€œ000:00:00โ€,

(โ€œ17:00:00โ€ - TIMENOW())

)

)

/ 60

)

  • (

SECOND(

[Pending Hours]

  • IF(

(โ€œ17:00:00โ€ < TIMENOW()),

โ€œ000:00:00โ€,

(โ€œ17:00:00โ€ - TIMENOW())

)

)

/ 3600

)

)

/ 8

)

  • 8,

โ€œ:00:00โ€ )

You then adjust Pending Hours the same way three times. Moving that to Adjusted Pending Hours with:

=[Pending Hours]

  • IF(

(โ€œ17:00:00โ€ < TIMENOW()),

โ€œ000:00:00โ€,

(โ€œ17:00:00โ€ - TIMENOW())

)

Your expression further reduces to:

[Pending Hours] - CONCATENATE(

FLOOR(

(

HOUR([Adjusted Pending Hours])

  • (MINUTE([Adjusted Pending Hours]) / 60)

  • (SECOND([Adjusted Pending Hours]) / 3600)

)

/ 8

)

  • 8,

โ€œ:00:00โ€ )

Iโ€™m trying to reduce the number of VCโ€™s because I had it working fine with 6 of them.

But I was getting different answers in the Form and Detail views

In one formula the 2 views were getting TRUE from 2 different sections of an IF equation.

I hypothesized that Appsheet was calculating the VCs in an odd order.

Or there was a race condition somewhere.

So I tried to condense them to eliminate this, but hit upon the maximum equation size.

So Iโ€™m redoing it from scratch.

Am I correct in thinking you canโ€™t multiply a duration?

You are correct: you cannot multiply a duration.

Itโ€™s more likely the bug is in AppSheet in the way form and detail view values are computed than with the number of VCs, Iโ€™d think.

Note, too, that Date, Time, and Duration values appear to only be automatically recognized if provided as literals in an expression. Your attempt to construct a Duration using CONCATENATE() will not be recognized as such, and instead be seen simply as a Text value. Then youโ€™re attempting to subtract Text from a numeric value.

Should I fudge that by doing something like โ€ฆ+โ€œ000:00:00โ€ ?

Top Labels in this Space