Shorten a formula
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Shorten a formula
Hello everyone
I have a formula that has a lot of conditions based on the values in columns C and D and based on the day name in column A
The formula is too long and I am trying to make it shorter
I have a formula that has a lot of conditions based on the values in columns C and D and based on the day name in column A
The formula is too long and I am trying to make it shorter
You do not have the required permissions to view the files attached to this post.
-
- 3StarLounger
- Posts: 254
- Joined: 15 Aug 2016, 11:23
Re: Shorten a formula
Hi,
Maybe you tell us what you want to do.
Why do those differences occur?
Between 08:00 and 20:00 there are 12 hours.
Why do 13 hours appear to you? an so on ...
Maybe you tell us what you want to do.
Why do those differences occur?
Between 08:00 and 20:00 there are 12 hours.
Why do 13 hours appear to you? an so on ...
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Re: Shorten a formula
Because it is multiplied by 1.25 as for all the days except Saturday and Sunday
And it is multiplied by 2 if the day is Friday. And it is multiplied by 1.5 if the day is Saturday.
And it is multiplied by 2 if the day is Friday. And it is multiplied by 1.5 if the day is Saturday.
-
- 3StarLounger
- Posts: 254
- Joined: 15 Aug 2016, 11:23
Re: Shorten a formula
All times shown are 08:00 - 20:00
Are there other working hours (eg: 22:00 - 06:00)?
If they are not, you can simplify the calculation formula.
Are there other working hours (eg: 22:00 - 06:00)?
If they are not, you can simplify the calculation formula.
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Re: Shorten a formula
There are different times in the real file.
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Re: Shorten a formula
I could use LET function and this is the solution
But the file will be used in older versions 2013 .. so LET will not work
Is there an alternative?
Code: Select all
=LET(X,((D3-C3+(D3<C3))*24),Y,IF(X<=8,X,X-(X-8)+(X-8)),IF(D3="","",IF(WEEKDAY(B3)=6,Y*2,IF(WEEKDAY(B3)=7,Y*1.5,IF(X<=8,X,X-(X-8)+(X-8)*1.25)))))
Is there an alternative?
-
- 3StarLounger
- Posts: 254
- Joined: 15 Aug 2016, 11:23
Re: Shorten a formula
I had asked if the work schedule could be overnight.
If not, the initial formula could be shortened (without checking if you work from one day to the next)
But I see you found a formula with LET (which can be reduced ...: D)
If not, the initial formula could be shortened (without checking if you work from one day to the next)
But I see you found a formula with LET (which can be reduced ...: D)
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Re: Shorten a formula
Yes the work could be overnight for some people. The LET is working on my office but the file will be shared and sent to someone who doesn't have office 365 and this LET will not work for him.
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Re: Shorten a formula
Any ideas in this topic?
-
- Administrator
- Posts: 78481
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Shorten a formula
Here are two options: a single formula and a formula using a helper column as replacement for LET.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Re: Shorten a formula
Amazing my tutor. Thanks a lot.
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Re: Shorten a formula
Can you please have a look at cells C4:D4 .. This is a case that I couldn't include as the person would attend 24 hours from 8 AM in a day to 8 AM the next day
How can this be included?
How can this be included?
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78481
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Shorten a formula
You should either store the date and time in columns C and D for all rows, or for none at all. Which do you prefer?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4913
- Joined: 31 Aug 2016, 09:02
Re: Shorten a formula
I am not sure what is the most perfect .. But I choose to store date and time in columns C and D to get all the possible occurrences.
-
- Administrator
- Posts: 78481
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Shorten a formula
See the attached version.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans