Nested IF, And excel formula - if-statement

Unfortunately I'm not a programmer, just a guy seeking help from those much more familiar than I. I'm trying to write a formula involving two cells. There are 4 outcomes based on 2 possible entries in each cell. What I'm wanting is if Cell A is High and Cell B is High, output Star. If A is High and B is low, Horse. If A is Low and B is high, puzzle. If both are low, Dog. Here's what I have:
=IF((And(K2="High",L2="High",Star),IF(And(K2="High",L2="Low", "Horse"),If(And(K2="Low",L2="High","Puzzle"),If(And(K2="Low",L2="Low","Dog))
Can anyone fix it for me?
Thank you,
Chad

You were close, but the () were in the wrong place.
=IF(AND(K2="High",L2="High"),"Star",IF(AND(K2="High",L2="Low"),"Horse",IF(AND(K2="Low",L2="High"),"Puzzle",IF(AND(K2="Low",L2="Low"),"Dog,"""))))

Related

Google Sheets ArrayFormula to Compare Multiple Cells from Different Rows

I'm making a checklist of Disney Blu-rays. Some Disney movies are available in 4K but some are not. I'm trying to create a column that will show if a movie release is available in a higher quality than the entry for that row.
Here is a simplified test sheet that should hopefully make my goal more clear...
https://docs.google.com/spreadsheets/d/1L2-npiEdTE9ardDi2q38sYhkKRFKAPCu_gtJFbOZa80/edit?usp=sharing
I've found a ton of ways to compare rows, look for duplicates, etc. But despite my limited but best efforts, I can't find a way to combine what I've found in a way that works towards this goal. The best I've been able to do is find duplicate titles but I've not been able to compare that against the Original Theatrical Release Year, and Blu-ray vs 4K release columns.
I'd like to do this through an ArrayFormula so that any rows I add are easily and automatically rendered into the formula without any extra work. Any help would be greatly appreciated! Thank you.
Here's my take on this:
=ArrayFormula(IFS(A3:A="",,COUNTIFS(A3:A,A3:A,B3:B,B3:B,D3:D,"4K",ROW(A3:A),">"&ROW(A3:A))*(D3:D<>"4K"),"Yes",1,"No"))
I'm not sure if I fully understood the task but the above formula seems to give the correct result.
try:
=INDEX(LAMBDA(a, b, c, d, LAMBDA(x, IF(a="",,
IF(IFERROR(x, "No")="No", "Yes", "No")))(VLOOKUP(a&d,
{FILTER(FILTER(a&d, b), NOT(COUNTIF(FILTER(a, c), FILTER(a, b))));
FILTER(FILTER(a&d, c), COUNTIF(FILTER(a, b), FILTER(a, c)))}, 1, )))
(A3:A&B3:B, C3:C="Blu-ray", D3:D="4K", ROW(B3:B)))

OpenOffice Calc SUM of TRUNC number cells, with rows that include text cells

RE: Apache OpenOffice 4.1.7, AOO417m1(Build:9800) - Rev. 46059c9192, 2019-09-03 12:04.
I need to sum non-integer entries across a range of cells, but without including the decimal values (complicated by some cells being text). I started with ROUNDDOWN, then TRUNC, then FLOOR. I'm driving myself nuts trying to find a clean code (or even an arbitrarily extensible ugly code) for what would be the following:
=SUMIF(ISTEXT(R7:CL7);0;TRUNC(R7:CL7))
The above doesn't work, of course, since TRUNC() doesn't apply to ranges, but it conveys what I'm trying to do in a nutshell -- some of the cells contain text, which SUM() ignores (luckily), but they flummox TRUNC, so I needed to handle the text problem.
I started with ISNUMBER, just to get the ball rolling; ISTEXT has fewer characters, but it's not worth fixing that right now.
FLOOR was equally disappointing for ranges:
=SUM(FLOOR(R7:T7;1))
I tried variations of =SUM(IF(... and searches for ROUNDDOWN range (and variations on that) and such pseudocode as "IFTEXT" and "SUMTRUNC" (and variations on that). I found info on ROUNDDOWN(SUM(... and so forth, but not "SUM(ROUNDDOWN(..." or any equivalent.
In my delirium, I got silly and even tried:
=SUMIF(ISTEXT(S7:U7);0;AND(TRUNC(S7);TRUNC(T7);TRUNC(U7)))
To be clear: {2.9→2 + 2.9→2 + 2.9→2 = 6} ≠ {2.9+2.9+2.9 = 8.7→8}. I'm looking for a 6, not an 8 (I'd joke about sixes and sevens, but I'm way past pumpkin o'clock and 2.428571 takes up too much space).
My current test-kludge is:
=SUM(IF(ISNUMBER(R7);ROUNDDOWN(R7);0);IF(ISNUMBER(S7);ROUNDDOWN(S7);0);IF(ISNUMBER(T7);ROUNDDOWN(T7);0); ... ;IF(ISNUMBER(AX7);ROUNDDOWN(AX7);0))
It ends at AX7 only because of the char count. I hope to SUM the whole row in a single sweep, but that ain't gonna cut it. I could do it in large chunks in multiple cells, and then add those cells up, but oy gevalt.
Since it's already ugly anyway, I could use the following to save a few characters, but this would only mean being able to extend the range maybe 6 further cells (not much point in that):
=IF(ISTEXT(R7);0;TRUNC(R7))+IF(ISTEXT(S7);0;TRUNC(S7))+IF(ISTEXT(S7);0;TRUNC(S7))
I'm seriously considering simply going down a bunch of rows (to below my data cells) and entering the following, then copying the cell and pasting it to a complementary range, and telling the SUM cells to just sum up their respectively shadowed rows (instead of the data rows that they sit in):
=IF(ISTEXT(R7);0;TRUNC(R7))
Sorry for the rambling; I need sleep. This started as a need, then multiple failed attempts became a grudge match of principle and obstinacy, and now I'm just plugging away at it out of blind habit developed over the past 2-3 days (hopefully I won't forget what the purpose was).
In summary...: ++?????++ Out of Cheese Error +++DIVIDE BY CUCUMBER.
I'm comfortable enough with macros, though it's been ~7 years (and that was in Excel). Thanks in advance, even if the answer is that I'm stuck with one of these! 🙂
EDIT: I don't see a way to attach a .csv here (though I could open the .csv with Notepad, and copy-and-paste the contents if that would help anyone), so here's a set of pics:

Google Sheet Not Multiplying in IF Formula

I am trying to calculate a price based on rates. If the number is $20,000 or below, there is a flat rate of $700. If the number is between 20,001.01 and $50,000, the rate is 3.5% of the number. The rates continue to lower as the numbers go up. I can get Google Sheets to populate the box with $700 if it is below $20,000 but I can't seem to make it do the multiplication for me. The cell just shows C4*.035
I want it to multiply the number shown in the C4 square by the percentage listed.
Here is the code as it currently sits:
=if(AND(C4<=20000),"700",IF(AND(C4>=20000.01,C4<=50000),"C4*.035", IF(AND(C4>=50000.01,C4<=100000),"C4*.0325", IF(AND(C4>=100000.01),"C4*.03"))))
Note, I know nothing about coding so I apologize if it is sloppy or doesn't make sense. I tried to copy and format based on an example that was semi similar to mine.
try:
=IF(C4<=20000, 700,
IF(AND(C4>=20000.01, C4<=50000), C4*0.035,
IF(AND(C4>=50000.01, C4<=100000), C4*0.0325,
IF(AND(C4>=100000.01), C4*0.03))))
As BigBen noticed in his comment - there's a mistake in your formula. You should not use " " around the formula if you don't want it to be read as a string.
Actually more clean solution is using IFS formula for this task.
=ifs(C4<=20000,700,
C4<=50000,C4*0.035,
C4<=100000,C4*0.0325,
C4>100000,C4*0.03)

Probability Models

What sort of tests are available in SAS that allow you to figure out what the probability of an event occurring is? And I do mean probability, not odds.
Specifically, I would like to know what is the probability a person might say yes vs. no to a particular type of surgery based on their age or insurance status?
I have tried logistic regression, but it appears to only return odds, and again, I am interested in a statistical test that returns probabilities, not odds.
You would think I could just google, "probability models (or tests) SAS" and get an answer, but strangely enough, I haven't - at least not one that is clear. So here I am.
Any help is appreciated. Thank you!
if you are getting odds from logistic regression. This is how the probability should be calculated.
Probability = odds/1+ odds

Python, getting a centered average with a catch

So, my assignment is to get the centered average of a list, much like a few of the other posts on here like this one (https://codereview.stackexchange.com/questions/108404/how-to-get-a-centered-mean-excluding-max-and-min-value-of-a-list-in-python) and a few others. However, my professor has told us we are not allowed to use min, max, or sort to solve this. So what I have right now is this, it is still a work in progress:
def centered_average(nums):
high=0
low=0
a=0
b=0
for i in range(len(nums)):
if nums[i]>a:
a=nums[i]
high=a
for i in range(len(nums)):
if nums[i]<b:
b=nums[i]
low=b
total=sum(nums)
average=(total-high-low)/(len(nums)-2)
print(average)
My problem is that I can't get low to be recognized as the lowest number in the list. For example, if I input [1,2,3,4,5] as the list, my function should return 5 as the high, 1 as the low, and 3 as the centered average since 2+3+4 is 9/3=3. However, what I have right there returns the low as 0. I think it is because of the (lens(nums) since it would think the first number is a 0. I'm not sure how I should fix this.
Note: I am still a beginner at this stuff so I know what I have might not be the best or that the error could be simple to fix, but I am still in the process of learning so any help and advice would be much appreciated.
The problem is your starting the running minimum (and running maximum) as 0.
Start the running minimum as float("inf") (as everything is guaranteed to be less than that). Start the running maximum as float("-inf") (as everything is guaranteed to be greater than that).
Or, start both as the first element of the list (which is either a true minimum/maximum, or there's another element that is lower/higher than it).