Salesforce - Row Level Formula - salesforce

I'm looking for some help with writing a row level formula in Salesforce. I'm looking to find records where the difference between the date of birth and the date of vaccine administration is less than or equal to 6573.5 days (17 years and 364 days). Image attached is where I am trying to write my formula.
I'm having trouble scripting the formula as Salesforce is quite new to me
I have gotten the below formula to work for me:
However I now need the application to check that the result of this formula is less than or equal to 6573.5 days, any help appreciated.

Related

How to check if any of the time ranges overlap with each other in Google Sheets [duplicate]

This question already has an answer here:
How to calculate the overlap between some Google Sheet time frames?
(1 answer)
Closed 1 year ago.
I found a thread already with the same question:
How to calculate the overlap between some Google Sheet time frames?
But I tried the same formula, altering it to match the ranges in my google sheet but it is not working.
Here is my google sheet:
https://docs.google.com/spreadsheets/d/19tk3H7G_FnJilXoPzU5on7m6yS33eWy2PhO2WonVUlg/edit?usp=sharing
This is the commenter view.
I gave it a range that should not have overlaps and I think it is this part of the formula which is giving me "True" for everything.
IF(C$29:C$42<D$29:D$42, True,
My goal is to search the range of times and see if any of them overlap but I am not sure how to accomplish it.
Edit: I noticed my array numbers were different 29 vs 42 so I have amended it. I added more times so there are now overlapping times and changed the range numbers
=ARRAYFORMULA(IF(I29:I56="",,
IF( I29:I56 < J28:J55, TRUE,
IF({""; I29:I56}<{""; J28:J55}, TRUE, ))))
the formula will work only if times are sorted:

Comparing two dates in array based on criteria in Excel

I am trying to find a formula which will compare two dates (Plan 1 minus Plan 2) and determine if they are within ninety days of each other.
The formula I have so far:
{=IF(E1<>"", IF(AND(MIN(IF(C:C=C1, IFERROR(E1-G1, -2), 0))<91, MIN(IF(C:C=C1, IFERROR(E1-G1, -2), 0))>-1), 1, 0), 0)}
The idea is that the array will loop though the Subjects in Column C and for every subject with a non-blank Plan 1 field (Column E), it will loop through the Plan 2 dates in Column G to find the closest one within ninety days. If one exists, the equation will give the Plan 1 a 1.
However, the formula above is not able to handle the dates seen below where there is no exact matching date in Column G.
Thank you for your help.
Scott Craner found the delightful equation below to answer this problem, except for the issue in the image below. It appears to be including a date greater than 90 days (orange highlight).
Use AGGREGATE:
=IF(E2<>"",IFERROR(--(AGGREGATE(15,7,(E2-$G$2:$G$21)/(($C$2:$C$21=C2)*(E2-$G$2:$G$21>=0)),1)<91),0),0)

Multiplying arrays resulting from multiplying arrays in Excel

I've tried looking through some of the posts and I'm having trouble finding something that will help me in this situation.
I have a spreadsheet that has Total Sales, Retail Price, and Inventory for each week in a year for a list of 100 or so projects. These three pieces of info are displayed as columns repeated for the year, with a row for each item.
I was able to add up the total annual cells (every 3rd column) using SUMPRODUCT((MOD(COLUMN(D3:L3),3)=0)*D3:L3)
The next goal is to get a formula to calculate the weighted average retail. I basically need to find a formula that will end up with the SUMPRODUCT of an array of Sales data and Retail data.
I have tried to use some layering of MMULT and SUMPRODUCT but keep getting #VALUE! errors. Particularly with SUMPRODUCT(TRANSPOSE(MMULT(TRANSPOSE((MOD(COLUMN(D3,L3),3)=0)),D3,L3)),MMULT(TRANSPOSE((MOD(COLUMN(D3,L3),3)=1)),D3,L3)) and with putting braces in there as well =SUMPRODUCT({TRANSPOSE(MMULT(TRANSPOSE((MOD(COLUMN(D3,L3),3)=0)),D3,L3))},{MMULT(TRANSPOSE((MOD(COLUMN(D3,L3),3)=1)),D3,L3)})
Does anyone have any experience with this type of issue? I feel like it should be something that Excel can do without having to have separate sheets to calculate.
For your weighted average:
=SUMPRODUCT(($D$2:$FD$2="Sales")*$D3:$FD3*$E3:$FE3)/SUMIF($D$2:$FD$2,"Sales",$D3:$FD3)
And also, to add up the Sales, you could consider:
=SUMIF($D$2:$FD$2,"Sales",$D3:$FD3)
I am assuming FD is the last column of data for the year, but change it if that is not the case.

Rolling Arrays as a possible solution to a rolling window in SAS

I am trying to calculate the dosage of a particular drug for a population to see if any member in this population is over a certain threshold for any 90 consecutive days. So to do this I am thinking that I am going to need to make a arraty that looks at the strengh of this drug over 90 days from an index and if they are all '1' then they get a 'pass', and somehow put this into a do loop to look at all of the potential 90 day windows for a year i=1...i=275 to see if a member at any point during the year has met the criteria. Thoughts?

Return the smallest value from a list, in which only certain values are eligeble - excel

I am having some troubles formulating my problem but I hope you understand!
I have a table of firms building production plants in foreign countries in certain years. (Columns A to C).
In a seperate table i have so-called cross-national distance measures (based on the difference in gdp of the countries). (Columns G to M). Note that the distances change per year.
A simplified version of the excel would look like this:
https://new.wu.ac.at/fileadmin/wu/d/i/iib/photo/stack.JPG
What I want is a formula for the manually entered results in column D. It shall give me a result which is the following:
It shall look in which countries the specific company has previously (years before) built plants
It shall find the smallest cross-national distance from the current country to any of the countries previously entered
The value should be for the year of the current plant-construction
Let me illustrate my request with the example result i would want in cell D8:
The formula would have to find a list of countries that were previously entered in this case Turkey and Bulgaria
It would then have to into the second table and give me the minimum of the distances from Kosovo but only to Turkey and Bulgaria
This would have to be done in the rows for 2008 (current year)
I really hope you guys can help me, i figured out a way to find a minimum in a list and i can do it for certain years as well but the issue i am having that excel first needs to find the previously entered countries, memorize them in some kind of array and then use only these countries to consider the minimum distance.
Thank you very much!
Try this "array formula" for D2 copied down
=IFERROR(SMALL(IF(COUNTIFS(A$2:A$11,A2,B$2:B$11,"<"&B2,C$2:C$11,"<>"&C2,C$2:C$11,I$1:M$1)*(G$2:G$31=B2)*(H$2:H$31=C2),I$2:M$31),1),"N/A")
confirmed with CTRL+SHIFT+ENTER
That checks three conditions for your larger table - that the header row matches a qualifying country (using COUNTIFS function based on criteria in the small table), that column G matches the current year and column H matches the current country.
If all those criteria are satisfied then the relevant values in the table are returned, and SMALL finds the smallest. If there's an error (because there are no qualifying values) then N/A is returned
In Excel 2010 or later versions you can use AGGREGATE function instead of SMALL - this is useful because it doesn't require "array entry"
=IFERROR(AGGREGATE(15,6,I$2:M$31/(COUNTIFS(A$2:A$11,A2,B$2:B$11,"<"&B2,C$2:C$11,"<>"&C2,C$2:C$11,I$1:M$1)>0)/(G$2:G$31=B2)/(H$2:H$31=C2),1),"N/A")

Resources