Best formula to get the number of days since ...

Best formula to get the number of days since last entry, filtered by name column?

0 15 1,872
15 REPLIES 15

@Kelly_VanAusdall Assuming that you have Date column in your table:

TODAY() - ANY(SELECT(TableName[Date],AND([Name]=[_THISROW].[Name],[_RowNumber]=MAX(SELECT(TableName[_RowNumber],[Name]=[_THISROW].[Name])))))

@Levent_KULACOGLU

Thanks for your helpโ€ฆ It says this is a valid expressionโ€ฆI changed it all to my table and column names.

Some it gives me -17695104:00:00 or โ€ฆfor a 7 day span it gives a result of 696.

For another with a 5 day span it shows 528.

Do I need to have a virtual column for Year and Month? If so, I think I need a formula for that too. Currently I do have virtual columns set up for those as Year([Date]) and Month([Date]) and Day([Date])

@Aleksi_Alkio that didnโ€™t work either. Returns 54 for a 7 day span. I even tried /168 the number of hours in a week.

If that formula doesnโ€™t work, the reason is not the formula itself. The reason is somewhere else.

Thatโ€™s what I assume. Just not sure where to look for a problem

If you send the account ID and app/table/column name to aleksi@appsheet.com, I could check the reason.

@Kelly_VanAusdall are all the column data is pure date format? MM/dd/yyyy and the type qualifier is set to Date as well?

One way is the expression MAXROW. Check this articleโ€ฆ

help.appsheet.com - List Expressions and Aggregates List Expressions and Aggregates help.appsheet.com

@Levent_KULACOGLU @Aleksi_Alkio

I have checked all Date columns to be sure they are in pure date format.

Type qualifiers are set to Date.

I have tried using MAXROW , however I canโ€™t seem to get it to work.

Table name is Weight Record Columns are:

Entry ID

Pig Name

Date

Weight Entry

Last Weight

Gain

Number of Days since last weight entry

Average Daily Gain (wk)

Date of Show Days Until Show

Projected Final

Seems like what I want to do is simple. I know Iโ€™m just not entering the perfect formulas.

I need to figure out the average daily gain for each animal. Then from there I will need to project a final weight based on the number of days until Date of Show.

So far I have [Last Weight] app formula =MAXROW(โ€˜Weight Recordโ€™, โ€œDateโ€, [Pig Name]=[_thisrow].[Pig Name])

In Gain column App Formula I have =[weight entry]-[last weight].[weight entry]

Gain from one entry to the next is working using the above.

Now I need the Number of Days since previous โ€œWeight Entryโ€.

Seems no matter what combination of formulas I use, I just canโ€™t find one that works.

Any help is appreciated.

I had all this working in my google spreadsheet, but one row would depend on the row above and I had all my animals on separate sheetsโ€ฆso I had to change it all up.

@Levent_KULACOGLU Do you have any other ideas why I canโ€™t get this to work?

How about TODAY()-[LAST WEIGHT].[DATE]?

@Aleksi_Alkio

Thanks, unfortunately that isnโ€™t working either.

The formula in the Last Weight Column (Ref Type-Ref Weight Record):

=MAXROW(โ€˜Weight Recordโ€™, โ€œDateโ€, [Pig Name]=[_thisrow].[Pig Name])

Here is formula in Number of Days Until Show Column: =Today()- [Last Weight].[Date]

It says the expression is Validโ€ฆ.and is

(TODAY() - The value of โ€˜Dateโ€™ from the row referenced by 'Last Weightโ€™

It returns 1272:00:00 between 7/1/2018 - 7/8/2018 1104:00:00 between 7/8/2018 - 7/10/2018 1056:00:00 between 7/10/2018 - 7/18/2018

I have made sure that the dates are all in pure date format. But is it something with the formatting of the cells?

@Aleksi_Alkio

Now I have moved on to working on another table.

Since I wasnโ€™t successful with Date Difference in the app formulas, I decided to just do in the spreadsheet itself.

The spreadsheet is showing the correct number of days difference in google sheets.

Looking at the app, the numbers displayed are completely off.

42 days on the spreadsheet is showing as 1008:00:00 on the appโ€ฆHELP!

For exemple 1272:00:00 is a duration and you need to read and convert it to days like HOUR([โ€ฆ] - [โ€ฆ])/24

Top Labels in this Space