Reapet n times each rows from query in google sheets - each
I try to have an output by query - reapeting each rows by formula in google sheets after match the term (term is text from cell - after choose from drop down list)
I'd like to Select a,b,c,f,g,h etc) and reapeting each column 7 times.
I have two formulas.
Now by Query formula on Output i have each row only one time.
And ArrayFormula to repeating - but it works only for 1 column
I'd like to combine 2 formulas below to choose all column and repeat each row 7 times.
=QUERY(MY_DICTIONARY!A5:F100; "SELECT a,b,c,f,g,h, WHERE A='"&F3&"'")
=SORT(TRIM(TRANSPOSE(SPLIT(QUERY(ARRAYFORMULA(
REPT(A8:A50&"♠"; 7)); ;999^99); "♠"))); 1; 0)
I will be extremely happy to any help.
maybe It will possible to combine 2 formulas into 1?
Edit 09:08
I add example file to show my problem.
example google sheet
I'm trying to combine Array formula for all columns.
But I discovered that it works well enough as a single Array of range each (D:D), (E:E), (F:F), (G:G).
=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY(
REPT(D4:D100&"♠"; 7); ;99^99); "♠"))))
=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY(
REPT(E4:E100&"♠"; 7); ;99^99); "♠"))))
=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY(
REPT(F4:F100&"♠"; 7); ;99^99); "♠"))))
=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY(
REPT(G4:G100&"♠"; 7); ;99^99); "♠"))))
Related
Excel AVERAGEIFS looking up ONE of the criteria columns
I have built a large data set and I need to see the average results given many different criteria. I've done this with the AVERAGEIFS function and it works just fine, however the more and more I add its getting really time intensive. I'm wondering if there is a way to nest a vlookup or index match or anything like that in the AVERAGEIFS that read the criteria column heading and criteria in a cell (or 2 if they need to be separated) to be added to the AVERAGEIFS. Here is an example of my spreadsheet: The first 3 sets of criteria I want to stay locked. I want it to read what the 4th criteria column and criteria should be by referencing the I11 cell. The highlighted portion in the formula bar is the part that I want to reference I11 so it reads it and knows that the 4th criteria is the 'code' column and the criteria is '>7'. I can separate this into 2 separate cells if need be. I've tried a few combinations of VLOOKUP and INDEX MATCH but cannot get it to work. Data as Text: Price,Type,sub cat,Time,code,amount,Result,, ,,,,,,,, 9.95,t2,d,ac,2.18," 22,780,893 ",0.73,,T2 and D and AC 118.94,u2,d,bo,2.78," 172,110,893 ",4.07,, 57.63,t1,u,ac,7.09," 128,419,877 ",-2.16,,code 8.88,t2,d,ac,1.50," 62,634,868 ",12.72,,amount < 100 000 000 11.61,u1,u,ac,2.14," 146,982,736 ",1.07,,price >10 13.46,u3,u,ac,0.93," 17,513,672 ",-13.93,, 31.53,t1,u,ac,0.89," 47,170,877 ",1.39,, 16.34,t3,d,bo,1.07," 1,914,767,076 ",-1.42,, 111.59,u1,d,bo,0.62," 2,283,546,000 ",0.67,, 72.4,u3,d,bo,10.37," 951,541,514 ",1.13,, 34.55,u3,d,bo,0.77," 951,541,514 ",-2.52,, 42.25,t1,d,bo,1.05," 63,748,352 ",8.88,, 17.18,u3,u,ac,2.64," 140,217,257 ",4.35,, 97.66,t1,d,bo,3.45," 1,070,383,954 ",1.33,, 58.49,t2,u,bo,8.64," 151,876,559 ",-0.92,, 64.48,t2,d,ac,2.35," 291,967,334 ",3.03,, 38.4,t1,u,ac,17.05," 83,478,472 ",-4.31,, 20.87,u3,d,ac,28.92," 214,080,937 ",-2.16,, 36.53,t1,d,ac,1.43," 73,438,589 ",-2.07,, 89.16,t3,u,ac,1.41," 26,786,958 ",-1.75,, 15.84,t1,u,bo,2.90," 133,560,818 ",1.76,, 3.2,u3,u,bo,2.95," 215,677,667 ",-1.06,, 25.46,t1,d,bo,3.92," 57,148,431 ",1.89,, 40,t2,d,ac,8.00," 65,274,903 ",0.61,, 27.72,t1,u,ac,2.50," 381,400,886 ",6.46,, 29.07,u3,u,ac,2.32," 52,632,107 ",-0.78,, 173.31,t1,d,ac,3.58," 31,547,380 ",-4.92,, 18.22,u3,d,ac,0.58," 292,669,493 ",4.06,, 9.59,t1,d,bo,3.60," 266,883,020 ",3.16,, 115.22,t2,d,bo,4.51," 132,376,476 ",0.78,, 64.48,u3,d,ac,3.03," 338,360,104 ",-0.95,, 41.74,t1,u,bo,25.65," 245,766,436 ",-3.42,, 5.99,t3,u,bo,2.15," 175,054,713 ",-4.37,,
Use INDEX/MATCH to return the correct column. This will require that you separate the column name and the criteria: =AVERAGEIFS(G:G,B:B,"T2",C:C,"D",D:D,"AC",INDEX(A:F,0,MATCH(I11,$A$7:$G$7,0)),J11)
An idea: I10 - "Write down the limitation. (You have to use <,>,=,<> AND the value, for e.g.: <5)" I11 - The user can use relations and values. In J11, you can reference to I11 ;) It works for me.
Find values occurring in multiple columns in excel
I have sets of gene probes that are upregulated when put under different chemical stresses. Each column contains all of the upregulated gene probes. I have 12 columns, how do I get a list of gene probes that appear in all 12 columns? I've been able to find similarities between two columns using the formula =IF(ISERROR(MATCH(A2,$C$2:$C$21473,0)),"",A2) but cant work out how to adapt it to include 12 columns G.Ac G.As G.At G.Ac.At G.As.Ac G.As.At G.Cd G.Cu G.Ni G.Cd.Cu G.Cd.Ni G.Ni.Cu GENE:JGI_V11_3346220103 GENE:JGI_V11_2653050203 GENE:JGI_V11_3299790103 GENE:JGI_V11_359040103 GENE:JGI_V11_2228010103 GENE:JGI_V11_2662750203 GENE:JGI_V11_1926920303 GENE:JGI_V11_3134270303 GENE:JGI_V11_3119540303 GENE:JGI_V11_3134270203 GENE:JGI_V11_1926920303 GENE:JGI_V11_3134270303 GENE:JGI_V11_3164760203 GENE:JGI_V11_565470303 GENE:JGI_V11_2296170203 GENE:JGI_V11_2045300203 GENE:JGI_V11_2421620203 GENE:JGI_V11_2228010303 GENE:JGI_V11_2196580303 GENE:JGI_V11_3134270203 GENE:JGI_V11_3119540203 GENE:JGI_V11_1926920103 GENE:JGI_V11_1926920103 GENE:JGI_V11_1014720202 GENE:JGI_V11_478830203 GENE:JGI_V11_3168730303 GENE:JGI_V11_3311070202 GENE:JGI_V11_3216620102 GENE:JGI_V11_2653050303 GENE:JGI_V11_3300140202 GENE:JGI_V11_2653050303 GENE:JGI_V11_1159220202 GENE:JGI_V11_2024180303 GENE:JGI_V11_1926920303 GENE:JGI_V11_2196580303 GENE:JGI_V11_1159220202 GENE:JGI_V11_3164760303 GENE:JGI_V11_2228010203 GENE:JGI_V11_2341670203 GENE:JGI_V11_1938910303 GENE:JGI_V11_3026230203 GENE:JGI_V11_2449230203 GENE:JGI_V11_3134270303 GENE:JGI_V11_2235750203 GENE:JGI_V11_1981410203 GENE:JGI_V11_3251310202 GENE:JGI_V11_977750103 GENE:JGI_V11_954070203 GENE:JGI_V11_2267320203 GENE:JGI_V11_2268000303 GENE:JGI_V11_2226270101 GENE:JGI_V11_3003640303 GENE:JGI_V11_223520203 GENE:JGI_V11_2662750103 GENE:JGI_V11_2228010103 GENE:JGI_V11_3251310202 GENE:JGI_V11_3198630203 GENE:JGI_V11_3134270303 GENE:JGI_V11_1926920203 GENE:JGI_V11_287750103 GENE:JGI_V11_465160203 GENE:JGI_V11_2268000203 GENE:JGI_V11_2473230303 GENE:JGI_V11_3192220102 GENE:JGI_V11_3026230303 GENE:JGI_V11_3039310303 GENE:JGI_V11_1926920103 GENE:JGI_V11_1159220102 GENE:JGI_V11_3052790202 GENE:JGI_V11_3075830303 GENE:JGI_V11_2196580203 GENE:JGI_V11_3134280203 GENE:JGI_V11_3142970303 GENE:JGI_V11_503720303 GENE:JGI_V11_2236410103 GENE:JGI_V11_3042230103 GENE:JGI_V11_2228010203 GENE:JGI_V11_3028210101 GENE:JGI_V11_2105710303 GENE:JGI_V11_1926920303 GENE:JGI_V11_2131620103 GENE:JGI_V11_1002840203 GENE:JGI_V11_2088480203 GENE:JGI_V11_3196120102 Heres the first 8 rows of the 12 columns. There are 21473 rows in total. Thanks
You could use an array formula like this to count how many columns a particular gene probe occurs in =SUM(--(MMULT(TRANSPOSE(ROW(A$2:L$10000)^0),N(A$2:L$10000=A2))>0)) This is a standard way of getting column totals for a 2D array - in this case an array of true/false values corresponding to instances of an array element being equal/unequal to A2. It is rather a brute force approach - it needs ~120K multiplications for each row. If you copy the formula down for ~10K rows, there is a delay of ~100 seconds on my computer while Excel works out the results. Must be entered as an array formula using CtrlShiftEnter In this dummy data C is the only value that occurs in all 12 columns.
Excel formulas - count based on two criteria
I've been struggling to get this formula to work. I have a spreadsheet where I need to find out how many of one column (BH2:BH915) contain a value (X) if another column (N2:N915) contains either 1 or 0. I've tried a bunch of versions to get it to work - this is the latest: =sum(countifs(N2:N915="1","0") and (BH2:BH915="X")) Can anyone tell me where I'm going wrong?
You'll need to add together the count of records with 0 and X and the count of records with 1 and X =COUNTIFS(N2:N915, 0, BH2:BH915, "X") + COUNTIFS(N2:N915, 1, BH2:BH915, "X")
You could also use =SUM(COUNTIFS(BH2:BH915,"x",N2:N915,{0,1})) or if you knew that the numbers in N2:N915 were integers =COUNTIFS(BH2:BH915,"x",N2:N915,">="&0,N2:N915,"<="&1)
Return a row number that matches multiple criteria in vbs excel
I need to be able to search my whole table for a row that matches multiple criteria. We use a program that outputs data in the form of a .csv file. It has rows that separate sets of data, each of these headers don't have any columns that are unique in of them self but if i searched the table for multiple values i should be able to pinpoint each header row. I know i can use Application.WorksheetFunction.Match to return a row on a single criteria but i need to search on two three or four criteria. In pseudo-code it would be something like this: Return row number were column A = bill & column B = Woods & column C = some other data
We need to work with arrays: There are 2 kinds of arrays: numeric {1,0,1,1,1,0,0,1} boolean {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE} to convert between them we can use: MATCH function MATCH(1,{1,0,1,1,1,0,0,1},0) -> will result {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE} simple multiplication {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}*{TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE} -> will result {1,0,1,1,1,0,0,1} you can can check an array in the match function, entering it like in the picture below, be warned that MATCH function WILL TREAT AN ARRAY AS AN "OR" FUNCTION (one match will result in true ie: MATCH(1,{1,0,1,1,1,0,0,1},0)=TRUE , YOU MUST CTR+SHIFT+ENTER !!! FOR IT TO GIVE AN ARRAY BACK!!! in the example below i show that i want to sum the hours of all the employees except the admin per case we have 2 options, the long simple way, the complicated fast way: long simple way D2=SUMPRODUCT(C2:C9,(A2=A2:A9)*("admin"<>B2:B9)) <<- SUMPRODUCT makes a multiplication basically A1={2,3,11,3,2,4,5,6}*{0,1,1,0,0,0,0,0} (IT MUST BE A NUMERIC ARRAY TO THE RIGHT IN SUMPRODUCT!!!) ie: A1=2*0+3*1+11*1+3*0+2*0+4*0+5*0+6*0 this causes a problem because if you drag the cell to autocomplete the rest of the cells, it will edit the lower and higher values of ie: D9=SUMPRODUCT(C9:C16,(A9=A9:A16)*("admin"<>B9:B16)), which is out of bounds same as the above if you have a table and want to view the results in a diferent order the fast complicated way D3=SUMPRODUCT(INDIRECT("c2:c9"),(A3=INDIRECT("a2:a9"))*("admin"<>INDIRECT("b2:b9"))) it's the same, except that INDIRECT was used on the cells that we want not be modified when autocompleting or table reorderings be warned that INDIRECT sometimes give VOLATILE ERROR,i recommend not using it on a single cell or using it only once in an array f* c* i cant post pictures :( table is: case emplyee hours totalHoursPerCaseWithoutAdmin 1 admin 2 14 1 him 3 14 1 her 11 14 2 him 3 5 2 her 2 5 3 you 4 10 3 admin 5 10 3 her 6 10 and for the functions to check the arrays, open the insert function button (it looks like and fx) then doubleclick MATCH and then if you enter inside the Lookup_array a value like A2=A2:A9 for our example it will give {TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE} that is because only the first 3 lines are from case=1
Something like this? Assuming that you data in in A1:C20 I am looking for "Bill" in A, "Woods" in B and "some other data" in C Change as applicable =IF(INDEX(A1:A20,MATCH("Bill",A1:A20,0),1)="Bill",IF(INDEX(B1:B20,MATCH("Woods",B1:B20,0),1)="Woods",IF(INDEX(C1:C20,MATCH("some other data",C1:C20,0),1)="some other data",MATCH("Bill",A1:A20,0),"Not Found"))) SNAPSHOT
I would use this array* formula (for three criteria): =MATCH(1,((Range1=Criterion1)*(Range2=Criterion2)*(Range3=Criterion3)),0) *commit with Ctrl+Shift+Enter
Excel VBA - Referring between ranges
Here's my problem: I have two ranges, r_products and r_ptypes which are from two different sheets, but of same length i.e. Set r_products = Worksheets("Products").Range("A2:A999") Set r_ptypes = Worksheets("SKUs").Range("B2:B999") I'm searching for something in r_products and I've to select the value at the same position in r_ptypes. The result of Find method is being stored in cellfound. Now, consider the following data: Sheet: Products A B C D 1 Product 2 S1 3 P1 4 P2 5 S2 6 S3 Sheet: SKUs A B C D 1 SKU 2 S1-RP003 3 P1-BQ900 4 P2-HE300 5 S2-NB280 6 S3-JN934 Now, when I search for S1, cellfound.Row gives me value 2, which is, as I understand, 2nd row in the total worksheet, but is actually 1st row in the range(A2:A999). When I use this cellfound.Row value to refer to r_ptypes.cells(cellfound.Row), It is taking it as an Index value and returns B3 (P1-BQ900) instead of what I want, i.e. B2 (S1-RP003). My question is how'll I find out the index number in cellfound? If not possible, how can I use Row number to extract data from r_ptypes?
Dante's solution above works fine. Also, I managed to get the index value using built in excel function Match instead of using Find method of a range. Listing it here for reference. indexval = Application.WorksheetFunction.Match("searchvalue", r_products, 0) Using the above, I'm now able to refer the rows in r_ptypes skuvalue = r_ptypes.Rows(indexval).Value
Because .Row always returns the absolute row number of a sheet, not the offset (i.e. index) in the range. So, just do some minus job to deal with it. For you example, r_ptypes.Cells(cellfound.Row - r_ptypes.Cells(1).Row + 1) or a little bit neat (?) With r_ptypes .Cells(cellfound.Row - .Cells(1).Row + 1) End With That is, get the row difference between cellfound and the first cell and + 1 because Excel counts cells from 1.