I am trying to add 1 condition to my formula using an OR statement.
My current formula is giving an INVALID DATA TYPE error when I have added the OR Statement however before I added the OR statement there were no errors, No criteria has changed anywhere in the data sets.
=IF(ISBLANK(Probability@row), "-", IF(OR(((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)) < 0, ((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)))), 0, 0.1 * ((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)))))
This is my Formula with No Error without the OR statement
=IF(ISBLANK(Probability@row), "-", IF((((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)) < 0), 0, 0.1 * ((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)))))
I need the OR statement to return 0 when YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row))> 10 when added into the OR however it gives INVALID Data Type Error
Best Answers
-
It looks like you have some issues with your parenthesis:
(YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row))> 10
-
If I am understanding correctly I would try this formula instead of using an Or statement.
=IF(ISBLANK(Probability@row), "-", IF((((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)) < 0), 0, IF((((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)) > 10), 0, 0.1) * ((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)))))
-
I meant that portion would go in the OR statement, but the parenthesis for that portion needed some slight adjustment.
-
Ok. So it looks like this portion is determining how many months have elapsed:
((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row)))
If we do a MOD/12, that should get it to reset to zero every 12 months.
MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)
Multiplying by .1 (as you did in your formula) will give you the appropriate 10% (10, 20, 30, etc.).
0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)
Subtracting that from 1 will essentially reverse the order so that you go 100, 90, 80, 70, etc..
1 - (0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12))
To stop it from going below zero, you would use a MAX function to either pull the percentage if it is a positive number or zero if the percentage is negative.
MAX(1 - (0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)), 0)
A little syntax adjustment to the first part of the IF and we should end up with:
IF(Probability@row <> "", MAX(1 - (0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)), 0), "-")
And that should be working for your Delay Weight formula.
The biggest adjustment is using the MAX function to essentially stop the countdown at zero and the MOD function to get it to reset every 12 months.
I haven't tested this in sheet though yet, so please make sure you test it for a wide range of dates and let me know how it works (or doesn't).
-
There is. It would be the same idea as using the MAX. I use this logic pretty regularly to keep % Complete based on date between 0% and 100%.
IF(Probability@row <> "", MIN(MAX(1 - (0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)), 0), 0.90), "-")
So you have your number and the MAX to keep it above zero
MAX(#, 0)
Then you treat the entire MAX function as a solitary number (since that is what it will output) and wrap it in the MIN.
MIN(max_output, 0.90)
Answers
-
It looks like you have some issues with your parenthesis:
(YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row))> 10
-
If I am understanding correctly I would try this formula instead of using an Or statement.
=IF(ISBLANK(Probability@row), "-", IF((((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)) < 0), 0, IF((((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)) > 10), 0, 0.1) * ((YEAR(TODAY()) - YEAR([Target date for Stage Gate 0 meeting P0.1]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target date for Stage Gate 0 meeting P0.1]@row)))))
-
I meant that portion would go in the OR statement, but the parenthesis for that portion needed some slight adjustment.
-
Thank you, I guess I would have another question on top of this now, if I were to try to have it loop so that after 12 months it starts counting again and after 24 months etc how would one go about that? So essentially 10 and 11 months after it always goes to 0 because the probability turns negative but 12 months after it resets? Do you know if there would be a way? Thanks again for the assistance it is appreciated!
-
Are you able to provide more context as to the overall flow? I'm not sure I follow exactly what you are trying to accomplish, but it almost sounds like you would need to incorporate the MOD function.
-
I am trying to have a loop essentially that a project loses 10% probability month over month, after 10 months there probability would be negative and not incorporated and the delay weight would be 0. At 12 months or 1 year it resets back to 0 and as the months increase the delay weight increases until 22 months etc. If that makes any sense
-
Would you be able to provide screenshots with some sample data? I understand what you are saying, but I can't quite visualize it.
The way I understand it is that you have a column of dates and a percentage. That percentage starts out at 100% in the current month, one month later is 90%, two months later is 80%, so on and so forth. 10, 11, and 12 months are all 0%. Then when we get to 13 months it goes back to 100% and starts the countdown all over again?
-
With May it should go back down to 0 as it has been 12 months. It starts at 90% and then decreases onward to 0 after 9 months so month 10 and 11 and 12 are 0 as you suggested and at month 13 it resets.
Initial Probability formula
=IF(Probability@row = "High", 0.9, IF(Probability@row = "Medium", 0.6, IF(Probability@row = "Low", 0.3)))Delay Weight
=IF(ISBLANK(Probability@row), "-", IF(OR(AND(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target Date of Start]@row)) > 9, ((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target Date of Start]@row)) < 12), AND(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target Date of Start]@row)) > 21, ((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target Date of Start]@row)) < 24), (((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12) + (MONTH(TODAY()) - MONTH([Target Date of Start]@row)) < 0)), 0, 0.1 * ((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row)))))
%probability
=IF(OR([Initial Probability]@row - [Delay Weight]@row < 0, [Delay Weight]@row < -10), 0, ([Initial Probability]@row - [Delay Weight]@row))
Again I appreciate your assistance
-
Ok. So it looks like this portion is determining how many months have elapsed:
((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row)))
If we do a MOD/12, that should get it to reset to zero every 12 months.
MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)
Multiplying by .1 (as you did in your formula) will give you the appropriate 10% (10, 20, 30, etc.).
0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)
Subtracting that from 1 will essentially reverse the order so that you go 100, 90, 80, 70, etc..
1 - (0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12))
To stop it from going below zero, you would use a MAX function to either pull the percentage if it is a positive number or zero if the percentage is negative.
MAX(1 - (0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)), 0)
A little syntax adjustment to the first part of the IF and we should end up with:
IF(Probability@row <> "", MAX(1 - (0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)), 0), "-")
And that should be working for your Delay Weight formula.
The biggest adjustment is using the MAX function to essentially stop the countdown at zero and the MOD function to get it to reset every 12 months.
I haven't tested this in sheet though yet, so please make sure you test it for a wide range of dates and let me know how it works (or doesn't).
-
This has been such a tremendous help Paul! I appreciate this so much thank you! So far it has been working very well! A final question would be is there a way do stop it after 90% with a Min for example if there is not that is not a big deal as this has been a tremendous leap from what I had. Thanks again!!!
-
There is. It would be the same idea as using the MAX. I use this logic pretty regularly to keep % Complete based on date between 0% and 100%.
IF(Probability@row <> "", MIN(MAX(1 - (0.10 * MOD(((YEAR(TODAY()) - YEAR([Target Date of Start]@row)) * 12 + (MONTH(TODAY()) - MONTH([Target Date of Start]@row))), 12)), 0), 0.90), "-")
So you have your number and the MAX to keep it above zero
MAX(#, 0)
Then you treat the entire MAX function as a solitary number (since that is what it will output) and wrap it in the MIN.
MIN(max_output, 0.90)
-
Thank you again! It worked!
-
Happy to help. 👍️
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 139 Industry Talk
- 471 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 496 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!