Repeat Columns of equation across rows infinitely - google-sheets

In Google Sheets, is there a way I can repeat columns of equations across rows laterally??
In [Pic1], I have a set of data from A1:C (in red color), listing out employee no., name and salary.
Below is the equations in yellow to show data in A10 =QUERY($A$2:$C$7,"Order by A Desc"), the equation in D10 is to multiple employee salary by 2 times =C10:C*2
Is there a way / any forumula I can type to keep on repeating A9:D set of equations across rows laterally like in [Pic2] (yellow)?
Manually copying and pasting across rows is very troublesome if copied in large amounts. It would be great is there is a formula way to achieve that.

try like this:
={A9:D, A9:D, A9:D, A9:D}

To concat multiple arrays horizontally, we can use array literals {arr1,arr2}. To automate this process, we can use REDUCE to loop and accumulate the arr multiple times:
=REDUCE(arr,SEQUENCE(number_of_times_to_repeat-1),LAMBDA(a,c,{a,arr}))
Sample:
To repeat A9:D three times,
=REDUCE(A9:D,SEQUENCE(2),LAMBDA(a,c,{a,A9:D}))

Related

Google Sheets: Have functions create cells if they run into existing data

This might not be possible, but I was curious if there was a way to make functions like =FILTER() and =UNIQUE() to create new cells if they run into data they cannot overwrite? I have a database composed of items from multiple sheets and as of right now I'm only able to use one filter function because of the nature of what I'm doing. Would be most convenient if something like this does exist, but a rather extensive round of google searching turned up no results
no, this is not possible, however, if your formulae are of the same size you can stack them up so if your dataset will grow then new rows should be auto-added. for example, if you have FILTER that outputs 3 columns & 5 rows today but tomorrow it will output 10 rows and under it you got UNIQUE that also outputs 3 columns & n rows, then you can do:
={FILTER(A:C, A:A<>""); {"","",""}; UNIQUE(D:F)}
{"","",""} acts as empty row as separator

Adding to a cells value based on two other cells

I'm wondering how I would go about adding to a cell based on two other cells.
For example, I'm creating a Google Sheets document to track profit & loss on certain things in an online game I play.
I'll try to explain this as best as possible.
If cell B71 is equal to the string in cell B7, increase the value in cell D71 equal to the number in cell D7.
However, the values will need to be compared to various other things depending on the item required.
For example, the string in cell B7 might change depending on what specific type of item is needed for that day as it does change daily.
I have cells near the bottom of the sheet which list the different type of item which will show the total amount of items used in that month.
I've tried to explain this a little better as requested below
I'm trying to make a spreadsheet that keeps track of the quantity of a specific item I use in a game for a daily task. This task can be done daily, and to keep track of profit & loss, I have created a spreadsheet to keep track of this.
So, each day, there are three different types of items (runes) that can be used in the machine to create an item called 'Vis Wax'. As Runes are cheap, creating the vis wax can generate a good profit. (I love working with data, hense the spreadsheet.
The image above shows what a daily section looks like. I input each type of rune (has to be 3), input the quantity used and the amount each rune is worth to create the total cost under Total.
Further down below, this table has been created
This will keep track of each rune and the amount used during that month.
So with that said, I'm looking for a solution so that if Air rune is entered in ANY of them slots with the QUANTITY used, it'll update that table accordinly (as well as the other runes that are used too). I've tried nested IF statements, but don't seem to have any luck. With the amount of checks that seem to be happening, I can't seem to find a working solution. As Air Rune might be in slot 1 one day, then slot 3 the next day. So it seems each cell in the Quantity Table will need to compare EACH cell in the daily section, to each rune type that can be used.
Hopefully that has explained it a little better.
Spreadsheet Link
https://docs.google.com/spreadsheets/d/1sYLpZJ46IpNk52gxMoJOIZsOCWToLkC4FF83RBncCf0/edit?usp=sharing
I would suggest you to use a different structure and take all the data from one day in one column, something like this:
In this way you will be able to extend the days keeping the formulas in a really simple way. Below, I will explain some useful formulas that you can use to lighten your work:
Day: =text(DAY(B2),"dddd")
Rune type: Check Data validation to create a drop-down list of your rune types
For counting how many runes have you used you can use SUMIFS function. It returns the sum of a range depending on multiple criteria. In your case, you need apply it three time per rune, as you can have the same rune in three different places. You see it with the following image:
The formula is: =SUMIFS($B$8:$H$8,$B$7:$H$7,A25) + SUMIFS($B$12:$H$12,$B$11:$H$11,A25) + SUMIFS($B$16:$H$16,$B$15:$H$15,A25). In this way you only need to write it once and you can fill the rest of the runes just dragging the mouse. If you need more days just change the column H with the last column that you want to take.
I assume that with all this information you can also keep track of your monthly statics easily. I suggest you to create a different sheet for each month.
I hope that my answer was useful, let me know if you have any doubt.
George, I agree with #fullfine, your data structure does not seem ideal for data analysis. And it doesn't seem that efficient for data entry either, with the sideways scrolling (at least on my screen).
But I recognise that you might not want to change it, perhaps having specific reasons for that layout, and having invested time in it. So I offer this formula as an alternative, which basically pulls the needed cells from your existing sheet, and comes up with the totals you'll need.
=QUERY(QUERY({B7:D9;G7:I9;L7:N9;Q7:S9;V7:X9;AA7:AC9;AF7:AH9;
B20:D22;G20:I22;L20:N22;Q20:S22;V20:X22;AA20:AC22;AF20:AH22;
B33:D35;G33:I35;L33:N35;Q33:S35;V33:X35;AA33:AC35;AF33:AH35;
B46:D48;G46:I48;L46:N48;Q46:S48;V46:X48;AA46:AC48;AF46:AH48;
B59:D61;G59:I61;L59:N61},
"select Col1, Col2, Col3*Col2 where Col1 <>'' order by Col1 label Col3*Col2 '' ",0),
"select Col1, sum(Col2), sum(Col3) group by Col1 label sum(Col2) '', sum(Col3) '' ",0)
The same formula can be used for each month, since it always totals all 31 days, even if the month has fewer days.
For your Rune table in the Statistics sheet, you only need the firsts two columns, so you could delete the "sum(Col3)" from the last select statement.
For your smaller financial table, you would take the sum of the Col3 produced by the above formula, ie. the total value of all the runes used. A similar formula would be used to collect the count of the wax produced, its value, and the profit/loss for each day. This would let you complete the financial table.
If you do decide to go with this approach, and want any help with completing the tables, or the formulas, please share your sheet so "anyone can edit it", to make it easier for me to assist you.

Excel/Sheets Consecutive Count Based on Two Conditions (function?)

I have a Google Sheet, and I'm trying to see if it's possible to get a consecutive count outputted in a third column based on the values of two other columns.
My columns are:
Column A: Will have a handful of text values that are "grouped" together. Likely around 30 of the same value, until it changes to another value. In the image above, these are text1, and text2.
Column B: Will have one of 3 values assigned to each value in column A. In the image above, these are id1, id2, id3.
Column C: Will output a consecutive count based on the values of the first two columns. My hope is that if there are multiple ID1,ID2 in consecutive order, they'll repeat that first +1 value; while ID3 is always plus 1 to the count. This is what I am trying to show in column C in the layout image above.
I've hit a wall with trying to accomplish this with various COUNTIF iterations.
Thanks for any help, or any better ideas to accomplish something similar.
(I'm hoping for a formula, but open to being pointed into a direction for a script if that's the only way).
You can try following formula:
=IF(A2=A1;IF(OR(B2="id3";B2<>B1);C1+1;C1);1)
It is also possible to do this as an array formula. I used offset ranges for column B in the first Countifs to check for a change in value but this made it a little awkward to get equal-sized arrays:
=ArrayFormula(if(A2:A="","",
countifs({"";B2:B}<>{B2:B;""},true,{A2:A;""},A2:A,row(A:A),"<"&row(A2:A),{B2:B;""},"<>id3")+
countifs(A2:A,A2:A,row(A2:A),"<="&row(A2:A),B2:B,"=id3")
))

match values from a range into each row of a table in Google Sheets

I've been working on a multi tiered drop down program, and in filtering one of the tables I stumbled upon a problem I can't find any help on.
Basically, I have 2 sheets. Sheet1!A2:A has a set of values. In this example, A2=110, A3=114, A4=162. However, with each use of the program, there could be any number of values and the values could change.
In the second sheet, Sheet2! there is a table. The first row has the headers that I want to return from my search. Under each header is a series of numbers ranging from 3 to well over 50 values. And the number of columns is also unknown...(it will keep getting larger).
So I want to know which columns have all 3 values from Sheet1!A2:A in them.
Column 3 might have 6 numbers (95,110,114,125,150,162) and column 7 might have (80,110,114,125) so I would want to return the header from Column 3 but not from column 7.
Does any of this make sense? Again in simple terms, I want to query all of the columns in Sheet2 to see which contain all of the values from Sheet1!A2:A
Any help would be so greatly appreciated...
-Daniel
I set up an sheet using your example data:
https://docs.google.com/spreadsheets/d/169VrbWkTlRMzhNPe4G8hQL1MdfqQuTvjb87aRD9hiWo/edit#gid=1923440782
I've restricted the formula in cell D2 to 500 rows for the sake of speed but you can remove the references to make it work across the whole sheet:
=FILTER(Sheet2!1:1,ArrayFormula(TRANSPOSE(mmult(TRANSPOSE(COUNTIF(A2:A500,Sheet2!A2:Z500)),TRANSPOSE(split(rept("1,",COLUMNS(TRANSPOSE(COUNTIF(A2:A500,Sheet2!A2:Z500)))),",")))=count(A2:A500))))

How do I create a top 3 chart list in google sheet

I have a column in google sheet that has random numbers from 1 to 20.
I want to create a chart that shows the top 3 numbers that occurred in that column.
Example:
Lucky numbers:
so on....
TIA
Let's assume the answer to my questions was 'yes', you want the three numbers that occur most often and how often they occur.
I've tried a couple of ways of doing this. One way is to sort the numbers and use FREQUENCY to get the frequencies. Then you could use a query like this to get the top 3
=query(A1:B20,"select A,B order by B desc limit 3")
Another way is to get the mode, then the mode excluding the most frequent, then the mode excluding both of the previous ones etc.
=ArrayFormula(mode(if(iserror(match(A$2:A$20,F$1:F1,0)),A$2:A$20)))
starting in F2 - you don't need to sort them.
Then you can just use COUNTIF to get how many times they occur.
Then just put them into a chart.

Resources