Criteria cutoffs for INDEX - excel

I'm not even sure how to ask this so please excuse the roundabout manner forthcoming.
I have a list of tasks and would like to use =INDEX to create my array. However, there are multiple different versions of the task that could show up, and I would like to have all possible avenues covered when creating (only 4 differences).
The name of the range is TaskCode. I want to have it so I can return the first seven numbers, the period, and then only the digits directly after the period. So in case 1, I would want 0527011.3, in case 2 I would want 0527011.01, in case 3 I would want 0527011.23, and in case 4 I'd want 0527011.3.
I initially did =LEFT(TaskCode,10) but that will obviously not work in case 1 or 4. Basically I need to say cut off EITHER at the second period OR the first blank.
Thanks

=LEFT(A2,FIND("|",SUBSTITUTE(A2&".",".","|",2))-1)

Related

Excel percentage increase based on formula

I am trying to fill the sell price column in an Excel spreadsheet with the increased values in colors based on the round up columns value (1 to 50 green, 50 to 100 blue, 100 to 150 yellow, 150+ pink).
I've opted for the percentage table because some items can be sold for a lot more than what I have purchased them for, so that's just for my benefit. I am open to any other suggestions and I am new to this whole business thing.
I was using IF in my formula which would work great for using one percentage increase in the formula:
=IF($E27<50,ROUNDUP(I$27,-1))
If I try to enter a second argument like
=IF(OR($E28<50,ROUNDUP(I$28,-1)OR($E28>50,<100,ROUNDUP(J$28,-1))))
I will get an error.
I'm probably using the formulas wrong, I've tried "AND" and a couple other formulas, but I can't find anyone else trying to achieve the same or similar.
So something like this:
=IF($E28<50,ROUNDUP(I$28,-1),IF($E28>50,ROUNDUP(J$28,-1),"Error"))
But not sure what the <100 was for.
Although the problem is not completely clear, I understand that you want to add a formula with nested if statements.
I will recommend you to try nested ifs in parts.
=IF($E27<50,ROUNDUP(I$27,-1),"First if condition is false")
If everything is working as per the requirement then edit that text in the formula to add another if statement.
=IF($E27<50,ROUNDUP(I$27,-1),IF(OR(condition 1, condition 2,more conditions),"value if true","value if false"))
In the second argument provided by you, the arguments of the OR function has not been properly provided. Ensure that all the arguments of an OR function are conditions separated by a comma.
$E28<50 This is a condition so it's ok.
But other arguments are not making sense.
Also, using OR multiple times inside the first OR arguments is not clear.
It would be beneficial if you could provide the basic table and mention the requirement clearly.

EXCEL: Match with either column

My question: Can you build a Match formula so that it matches with either column A or B?
Process is a bit convoluted but will try to make it as clear as possible; maybe someone can come up with a better way to do this that doesn't even involve an index-match formula.
I have a data set that looks something like this:
Match 1 // Team 1 // Team 2 // Winner: Team 1
Match 2 // Team 1 // Team 3 // Winner: Team 3
I want to be able to track previous performances (i.e. team results in the last 4 matches for example), to be able to use that to predict the winner. To do so, I am building a table that looks something like this:
Team 1 Match 1 // Result (0 or 1)
Team 1 Match 2 // Result (0 or 1)
Problem is, to be able to tell whether or not Team 1 played in Match 1, I need to check 2 columns and I can't find anything on using match with an OR logic (have used it with an AND logic before).
I can think of some brute force solutions (like duplicating each match so that it only has 1 team and whether or not they won), but the problem is I have 20 thousand lines of matches and hundreds of different teams, so inefficiency destroys my computer. If you see a more elegant way of doing this I am all ears!
Any thoughts?
After thinking about it for a bit, I found a way of doing it, although its not particularly elegant. The pseudo formula:
=IF(match("Team 1"; column1;0) > match("Team 1"; column2;0); index(using column2); index(using column1))
Then it is a matter of using Indirect to make the range that is being checked start after the previous matched row.

Sumproduct with multiple criteria on one range

In a dataset I have answers that participants to a survey gave. The answers are in one example numbered 1 to 5, with 1 being yes, and 2 to 5 being variants of no.
20 or so similar questions have been asked, and participants can be in either one of 20 subgroups. Questions were categorized into 6 classes.
Now the best way to go about such a dataset would normally be the use of a pivot-table, however the way the data is set up doesn't work with a pivot table, and due to the sheer size of the dataset remodelling isn't efficient.
To extract the amount of people in a certain subgroup that answered yes for questions in a certain class I use the following function:
=SuMPRODUCT(--(Test!D$4:$CC$1824=1)*(Test!$C$4:$C$1824=$C3)*(Test!$D$3:$CC$3=D$2))
In which Test!D$4:$CC$1824 is the range where answers are given, and the other two are ranges for subgroup and classes respectively.
By using --(Test!D$4:$CC$1824=1) I convert all data to 0's except for where participants answered yes (cell value = 1).
Now I would like to do the same thing for where they answered no, so the value is either 2 or 3 or 4 or 5. The ideal way would be to append some OR logic into the first test, coming about something like this: --(Test!D$4:$CC$1824={2,3,4,5})
Ofcourse this doesn't work, but is there any simple notation besides retyping the first part 4 times, and adding them together?
I'd say you could just use >1 instead of =1
For selected results like 1 and 3 and 5 you probably need to add the sumproducts of each number.
Sidenote: the -- is not necessary anymore as it is just for converting true and false to 1 and 0 when there is only one bracket inside sumproduct
The OR operation can be mimicked by adding all of the possibilities together.
=SuMPRODUCT(((Test!D$4:$CC$1824=2)+(Test!D$4:$CC$1824=3)+(Test!D$4:$CC$1824=4)+(Test!D$4:$CC$1824=5))*
(Test!$C$4:$C$1824=$C3)*(Test!$D$3:$CC$3=D$2))
If there is any possibilitiy that two could be correct (in this case there isn't) wrap the sum in the SIGN function to get only zero or one.
=SuMPRODUCT(SIGN((Test!D$4:$CC$1824=2)+(Test!D$4:$CC$1824=3)+(Test!D$4:$CC$1824=4)+(Test!D$4:$CC$1824=5))*
(Test!$C$4:$C$1824=$C3)*(Test!$D$3:$CC$3=D$2))

Excel small mistake in function

I'm having a small problem with my formula in excel. I got a long list with IDs from different people numbered from 1 to 20535 for which I want to calculate the portfolio return. One ID has multiple lines so the ID is repeated over multiple lines depending on their number of investments.
This is the formula (it's working perfectly except for the bold)
=IF(B3=1;SUMIF($B$2:$B$357553;V3;$D$2:$D$357553);B4=B3+1)+IF(B3=1;SUMIF($G$2:$G$187396;V3;$I$2:$I$187396);B4=B3+1)+IF(B3=1;SUMIF($M$2:$M$544950;V3;$O$2:$O$544950);B4=B3+1)+IF(B3=1;SUMIF($R$2:$R$131523;V3;$T$2:$T$131523);B4=B3+1)
The only mistake is the part in bold. Once I get to the second person (so the second ID) it stops as the condition is not met anymore. How can I make it run past the first person? So untill ID 20535.
Thanks in advance!
Since you just want the TRUE part of the IF each time, just remove the IF and use the SUMIFs:
=SUMIF($B$2:$B$357553;V2;$D$2:$D$357553)+SUMIF($G$2:$G$187396;V2;$I$2:$I$187396‌​)+SUMIF($M$2:$M$544950;V2;$O$2:$O$544950)+SUMIF($R$2:$R$131523;V2;$T$2:$T$131523)‌​
Put the above in row 2 and copy down. That should do it.

Amazon Cloud Search - get places by time and date

I am using Amazon CloudSearch to store a large set of places.
Each place has a opening time and a closing time, for each day of the week.
I need to retrieve places by current time. How do you suggest to model the index?
I am thinking to solve the problem by creating 7 text indexes in which I specify, for each day of the week, the valid hours.
For example, if a place is opened from 9 am to 13 am, in the index "monday" I will write the string "9-10-11-12". Then, filtering by bq=monday:'10' or bq=monday:'16' I will have only the places that at the specified time are opened.
Any other idea? My solution seems working but would suggest me another approach?
First, I wouldn't use multiple indexes.
You could use your approach, but just make the time in hours from the start of the week. So, Monday would be 0-23, Tuesday 24-47, etc. Or you could just have 7 fields, "monday_hours", "tuesday_hours", …
You could also use uints, instead of strings. Not better, but different, might be worth benchmarking.
With uints you can use range queries. If the document contained the fields "open" and "close" and you want to know if it's open between 10 and 12.
&bq=(and open:..12 close:10..)
One issue remaining is that CloudSearch's range searches are inclusive of endpoints. So I think this will show a false positive if the store opens at twelve. Technically, the ranges overlap, but not usefully. To fix that, I'd do two things. First, I wouldn't go by hours, I'd use minute-of-the-day as the value in the field (0 to 1439). Then add one to the starting range, and subtract one from the end.
Using uints will perform differently from using text fields. I'd definitely benchmark them to see which one works better for you.

Resources