I'm trying to combine 4 different Array formula's. I have tried some suggestions on this site but they didn't work.
Here's a couple I tried:
ARRAYFORMULA(IF(AND(K6>0,K6<=15),VLOOKUP(D5,Data!$F$2:$L$7,2,FALSE),0))
ARRAYFORMULA(IF(AND(K6>=16,K6<=99),VLOOKUP(D5,Data!$F$2:$L$7,3,FALSE)))*K6
ARRAYFORMULA(IF(AND(K6>=100,K6<=249),VLOOKUP(D5,Data!$F$2:$L$7,4,FALSE)))*K6
ARRAYFORMULA(IF(AND(K6>=250,K6<=499),VLOOKUP(D5,Data!$F$2:$L$7,5,FALSE)))*K6
Hope someone can help make this formula.
First have to mention that using of ArrayFormula is doing nothing in your formulas. So I've got rid of it in my solution.
I've made helper table to make it one formula:
Then I've made 3 steps.
Step 1. Find column of vlookup
Use vlookup with sorted table to find the number of column to return:
=VLOOKUP(K6,$R$2:$T$5,2)
Step 2. Find the multiplier
I see in the first formula you don't multiply *K6
But you need one formula to match all conditions. So we use power of number:
K6 ^ 0 = 1
K6 ^ 1 = K6
To get the power I used my helper table again:
=VLOOKUP(K6,$R$2:$T$5,3)
Step 3. Combine the formula
The last thing is to get all this done in one formula:
=IF(AND(K6>0,K6<=499),VLOOKUP(D5,Data!$F$2:$L$7,VLOOKUP(K6,$R$2:$T$5,2),FALSE),0)
*K6^VLOOKUP(K6,$R$2:$T$5,3)
I still use if-and in order to prevent errors in my vlookup part of the formula.
Just to add an option to #Max Makhrov. I modified the 'IF' statement to put the '^' inside the core VLOOKUP section. If K6 breaks the if-and rule then the final '^' VLOOKUP would likely error as out-of-bounds. So
=IF(AND(K6>0,K6<=499),VLOOKUP(D5,Data!$F$2:$L$7,VLOOKUP(K6,$R$2:$T$5,2),FALSE)*K6^VLOOKUP(K6,$R$2:$T$5,3),0)
Related
I have a big sheet raw_data which is automatically populated by a script every 5 minutes. As such I cannot add new columns with formulas but have to solve problems in single formulas.
The challenge:
I need to pull out a list of unique values from a column O. At the same time, I need to filter out a certain set of values in range A55:A
I have this formula to pull out the unique values:
=SORT(UNIQUE(raw_data!O2:O))
I tried playing with match, but how do I "inverse" the result from the match as I'm actually looking to
exclude rather than include:
=SORT(UNIQUE(FILTER(raw_data!O2:O,IFERROR((Match(raw_data!O2:O,A75:A200,0))))))
I tried adding a NOT() around the Match() but that then gave me a no results error.
Anyone?
Instead of using NOT use ISNA
The above because MATCH returns #N/A when there is no match.
Related
Return FALSE for #N/A in if match statement
Filter out all of user's entries if one of them was selected
I am trying to find the "real" formula of a group. For example, these are the formulas
=If(A$4>$A1,"Long","Short")
=If(B$4>$A1,"Long","Short")
=If(A$4>$A2,"Long","Short")
=If(A$4>$A$2,"Long","Short)
The forth formula is a different one. The first 3 formulas should be the same formula that is a cell fixed 4th row compare to a cell fixed at column A. The result should show 2 "real" formula. Something like this
=If($4>$A,"Long","Short")
=If($4>$A$2,"Long","Short")
How do I design a regex (or any other method) in VBA to extract that "real" formula from the "nominal" formulas?
Convert your formulas to display in R1C1 format by using File,Options,Formulas and ticking R1C1 style. In such a style your four example formulas would display (If they were entered in column 3) as
=IF(R4C[-2]>RC1,"Long","Short")
=IF(R4C[-1]>R[-1]C1,"Long","Short")
=IF(R4C[-2]>R[-1]C1,"Long","Short")
=IF(R4C[-2]>R2C1,"Long","Short")
The fixed portions of the addresses don't have braces [] so if you remove the braces and their contents you get
R4C>RC1
R4C>RC1
R4C>RC1
R4C>R2C1
and no 4 is different from the others
Question 1 - Is Tableau able to use multiple results from from a single line in a REGEXP using the global variable to compare against another table during a Join operation? If no, question 2 is null. If yes...
Question 2 - I'm attempting to join two data sources in Tableau using a regexp in a calculated join because the left table has 1 value in each cell (ie. 64826) and the right table has 4 possible matches in each cell (ie. 00000|00000|21678|64826).
The problem is that my regex stops looking after it finds 1 match (the first of 4 values), and the global variable /g has the opposite effect I expected and eliminates all matches.
I've tried calculated joins on the Data Source tab. I've also tried separating those 4 values into their own columns in worksheets using
regexp_extract_nth. In both cases, regex stops looking after the first result. A Left Join seems to work somewhat, while an Outer Join returns nothing.
REGEXP_EXTRACT([Event Number],'(\d{5})')
REGEXP_EXTRACT_NTH([Event Number],'(?!0{5})(\d{5})',1)
With these examples, regex would match a NULL with the left table even though 64826 is in the right table. I expect the calculated join to return all possible matches from the right set, so there'd be a match on 21678 and on 64826, duplicating rows in the right table like so...
21678 - 00000|00000|21678|64826
64826 - 00000|00000|21678|64826
45245 - 45106|45245|00000|00000
45106 - 45106|45245|00000|00000
Your original expression is just fine, we might want to make sure that we are sending a right command in Tableau, which I'm not so sure, maybe let's try an expression similar to:
\b([^0]....)\b
even just for testing, then maybe let's modify our commands to:
REGEXP_EXTRACT([Event Number], '\b([^0]....)\b')
or:
REGEXP_EXTRACT_NTH([Event Number], '\b([^0]....)\b', 1)
to see what happens. I'm assuming that the desired numbers won't be starting with 0.
Please see the demo here
Reference
I'm trying to apply a formula without having it add the formula data to each and every cell - in other words, I need the cells that are receiving the formula to be untouched until they get their data.
I was searching around and it looked like an ARRAYFORMULA would work but it doesn't seem to be doing anything when I apply it.
For example, I want to apply this formula to a cell range: =SPLIT(E2, ",")). Each cell in the E column needs to be split into two the two adjacent cells next to it based on it's comma. When I try to apply =ARRAYFORMULA(SPLIT(E2:E99, ",")) only the cell I add this to gets the formula.
In addition to the contribution of pnuts, also try:
=ArrayFormula(iferror(REGEXEXTRACT(","&E2:E,"^"&REPT(",+[^,]+",COLUMN(OFFSET(A1,,,1,6))-1)&",+([^,]+)")))
Note: the last parameter of OFFSET can be changed to match the maximum number of values you have in the cells of the range E2:E (separated by a comma). E.g: if you have a no more than 3 values per cell, set it to three. The output will then be three columns wide (one column for each value).
Hope that makes sense ?
Also credits due to AdamL who (I believe) orginally crafted this workaround.
I think what you want may be array_constrain but for your example I can only at present offer you two formulae (one for each side of the comma):
=Array_constrain(arrayformula(left(E2:E,find(",",E2:E)-1)),match("xxx",E:E)-1,1)
=Array_constrain(arrayformula(mid(E2:E,find(",",E2:E)+1,len(E2:E))),match("xxx",E:E)-1,1)
I want to convert an input to desired output. Kindly help.
In the output - the columns value should start from most recent (year)
Please click this to see data
Unfortunately VLOOKUP is not able to fulfill that ask. However the INDEX-function can.
Here is a good read on how to use it:
http://fiveminutelessons.com/learn-microsoft-excel/use-index-lookup-multiple-values-list
This will work for you spreedsheet, if your input table starts at A1 without a header and your output table starts at H3 with the first ID.
You get this by copy&pasting the first column of your input table to column H and then remove duplicates.
{=IF(ISERROR(INDEX($A$1:$C$7,SMALL(IF($A$1:$A$7=$H$3,ROW($A$1:$A$7)),ROW(1:1)),3)),"",
INDEX($A$1:$C$7;SMALL(IF($A$1:$A$7=$H$3,ROW($A$1:$A$7)),ROW(1:1)),3))}
Let's look at the formula step by step:
The curly brackets tell excel that this is an array formula, the interesting part for you is: when you've inserted the formula (without curly brackets) press shift+ctrl+enter, excel will then know that this is an array formula.
'error at formula?, then blank, else formula
=IF(ISERROR(....),"",...)
When you autofill this formula you probably dont know how many instances of your lookup variable are. So when you put this formula in 4 cells, but there are only 3 entries, this bit will keep the cell blank instead of giving an error.
INDEX($A$1:$C$7,SMALL(IF($A$1:$A$7=$H$3,ROW($A$1:$A$7)),ROW(1:1)),3))
$A$1:$C$7 is your data matrix. Your IDs (in your case 125 and 501) are to be found in $A$1:$A$7. ROW(1:1) is the absolute(!) rowID, 3 the absolute(!) column id. So when you move your input table those values have to be changed.
What exactly SMALL and INDEX do are well described in the link above. (Or at least better than I could.)
Hope that clarified some parts,
Tom