Google Sheets Transpose last columns values - google-sheets

I have this table in Google Sheets
Month 1 2 3 ...
1 20 30 45
2 32 47
3 53
...
How do I Transpose the last value of each columns into this?
Month lastValue
1 20
2 32
3 53
...

Although I'm not sure whether I could correctly understand your question, in your situation, how about the following sample formula?
Sample formula:
=BYROW(B2:D,LAMBDA(x,IFERROR(INDEX(SPLIT(TEXTJOIN(",",TRUE,x),","),1))))
In this formula, in order to start no empty cell, I used TEXTJOIN and SPLIT. And, the 1st cell is retrieved. I used this with BYROW.
As another approach, this formula =BYROW(B2:D,LAMBDA(x,IFERROR(INDEX(FILTER(x,x<>""),1)))) might be able to be also used.
Testing:
When this formula is used in your provided situation, the following result is obtained.
References:
TEXTJOIN
SPLIT
BYROW

Related

Spreadsheet, result of multiple connected formulas depending on value from list

A little bit frustrating as I knew how to do it years ago and right now I can't event ask Google accurate question to find the answer so I'm comming here :)
The sample spreadsheet will be almost self explanatory:
https://ethercalc.net/onpoo16pjeld
Extremely simplified version would be:
A | B
1 | input: |100
2 | formula1 |=B1 * 1.5
3 | formula2 |=B2 + 20
4 | 90 |=result of B3 when B1 = A4
5 | 150 |=result of B3 when B1 = A5
6 | 200 |=result of B3 when B1 = A6
I need result of last formula in the chain basing on different initial values.
I'll appreciate Google Sheet formulas, thank you.
My interpretation of the question is that you are asking for something like Excel's 'Data Tables' function, where (given some sort of mathematical model where the logic is chained over multiple cells from 1 or 2 input cell(s) each containing a single value into one output cell) the user can define the input and output cells and then create a table where Excel feeds multiple values into the input cell(s) and records the output value for each one according to the model. Google Sheets doesn't natively support this; the add-on below claims to replicate the Data Table functionality (https://workspace.google.com/marketplace/app/whatif/430660745752) but I have no experience with it. The 'best' option is still probably to condense all the logic into one arrayformula as per Tedinoz's answer - if there's a concern that this will make the model more difficult to understand because the individual steps are no longer spread out over multiple cells then it should be possible to use LAMBDAs to label all the steps to make the arrayformula easier to follow.
This formula assumes that the value in Cell B2 = Cell B1 x 120%
Enter this formula in cell F2:
=arrayformula(((E2:E7+(E2:E7*2/5))*1.15)+ (IF((E2:E7*2/5)>150, 50, 80)))
Output

Google Sheet - It's possible to array sum function in the following condition?

Would it be possible to use arrayformular for this condition?
Sum all the rows that PID are the same, the result should be as in the image.
I tried this code, but I think it's too long, and if the PID exceed over 20 rows, it would not work.
=IF(A3<>A2,BJ3+IF(A3=A4,BJ4,0)+IF(A3=A5,BJ5,0)+IF(A3=A6,BJ6,0)+IF(A3=A7,BJ7,0)+IF(A3=A8,BJ8,0)+IF(A3=A9,BJ9,0)+IF(A3=A10,BJ10,0)+IF(A3=A11,BJ11,0)+IF(A3=A12,BJ12,0)+IF(A3=A13,BJ13,0)+IF(A3=A14,BJ14,0)+IF(A3=A15,BJ15,0)+IF(A3=A16,BJ16,0)+IF(A3=A17,BJ17,0)+IF(A3=A18,BJ18,0)+IF(A3=A19,BJ19,0)+IF(A3=A20,BJ20,0)+IF(A3=A21,BJ21,0)+IF(A3=A22,BJ22,0),0)
With a table like this :
ID
Value
1
5
1
10
2
5
2
10
2
15
You have an expected output of :
ID
Value
Sum
1
5
15
1
10
blank
2
5
30
2
10
blank
2
15
blank
It is achievable with this formula (just drag it in your sum column) :
=IF(A2=A1,"",SUMIFS(B$2:B$12,A$2:A$12,A2))
It check if the ids are the same and then sum them, but only show them on the row where the id first appears
Found it on google by searching google sheets sum group by
The following in C2 will generate the required answer without any copying-down required:
=arrayformula(if(len(A2:A),ifna(vlookup(row(A2:A),query({row(A2:B),A2:B},"select min(Col1),sum(Col3) where Col2 is not null group by Col2"),2,false)),))
We are making a lookup table of grouped sums against the first row of each 'P#' group using QUERY, then using VLOOKUP to distribute the group sums to the first row in each group. Probably also doable using a SCAN/OFFSET combination as well, I think.

How to apply array formula taking data from another table?

We have two tables in Google Sheets.
First:
Date
Amount
Currency
Worth
01.01.2021
100
USD
373
02.01.2021
100
EUR
451
03.01.2021
100
PLN
100
04.01.2021
100
USD
373
05.01.2021
100
USD
372
Second:
Date
PLN
EUR
USD
01.01.2021
1
4,50
3,73
02.01.2021
1
4,51
3,75
03.01.2021
1
4,50
3,74
04.01.2021
1
4,48
3,73
05.01.2021
1
4,49
3,72
I tried find array formula for first table, column Worth. Formula should take proper value from second table (based on two columns from table one - Date and Currency) and multiply that values by worth in column Amount. I really want to use array formula. Is it possible?
Use VLOOKUP to find the correct date row and MATCH to find which column the value is in:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A,I2:L,MATCH(C2:C,I1:L1,0))*B2:B))
Option 01: Getting the result with one cell one formula.
Paste this in B3 "Amount" column in the first table, take a look at this Sheet.
=ArrayFormula(IF(ArrayFormula(IF(A3:A="",,VLOOKUP(A3:A,G3:J,ArrayFormula(IF(D3:D="",,MATCH(D3:D,$H$2:$J$2,0)+1)),0)))="",,ArrayFormula(IF(A3:A="",,VLOOKUP(A3:A,G3:J,ArrayFormula(IF(D3:D="",,MATCH(D3:D,$H$2:$J$2,0)+1)),0)))*E3:E))
Explanation ...
1 - MATCH(D3:D,$H$2:$J$2,0) To get the index you want to VLOOKUP the "Currency" column from the second table with, we need that in the next step.
2 - VLOOKUP the "date" found in First table A3:A from Range in the second table G3:J, with Index set to MATCH(D3:D,$H$2:$J$2,0), and [is_sorted] set to 0
3 - till now we have the value of the exchange rate if we can call it that for each Currency chosen in the first Table, we need to multiply it by Worth to get Amount
ArrayFormula(IF(A3:A="",,VLOOKUP(A3:A,G3:J,ArrayFormula(IF(D3:D="",,MATCH(D3:D,$H$2:$J$2,0)+1)),0)))*E3:E is structured like this Exchange rate * Amount note that E3:E is the Amount, and this IF(A3:A="",, to calculate only when A3:A range is not blank.
4 - ArrayFormula and a IF is needed to be wrapped around like this ArrayFormula(IF(Range=Empty,Do nothing,formula)
Range:
ArrayFormula(IF(A3:A="",,VLOOKUP(A3:A,G3:J,ArrayFormula(IF(D3:D="",,MATCH(D3:D,$H$2:$J$2,0)+1)),0)))
Empty
""
Do nothing :
,,
Formula:
ArrayFormula(IF(A3:A="",,VLOOKUP(A3:A,G3:J,ArrayFormula(IF(D3:D="",,MATCH(D3:D,$H$2:$J$2,0)+1)),0)))*E3:E
Option 02: Getting the result with intermediate steps.
Same as option 01 but in seprate columns take a look at this Sheet.

Google Sheets - Using ArrayFormula with Conditional and Embedded Formula

This may be far more simple than I think. What I'm trying to do is use the ArrayFormula to copy an existing formula to all the rows in a particular column.
To begin with, I have several columns along the lines of:
What I'm doing is adding the first three numbers and multiplying them by the fourth. I also have an IF condition in which, if the fourth column is blank, I leave the value in column 5 blank.
Now, I'm trying to convert this to an ArrayFormula to repeat this for all the rows in column 5.
So I went from:
=IF(ISBLANK(E2)=TRUE,,SUM((B2+C2+D2)*E2))
to this:
=ArrayFormula(IF(ISBLANK(E2:E)=TRUE,,SUM((B2+C2+D2)*E2)))
But what this does is, when I add a new row, ALL of the values in column 5 are set to the same value. Here is an example:
So, my first thought was to set the range on the SUM formula and change it to:
=ArrayFormula(IF(ISBLANK(E2:E)=TRUE,,SUM((B2:B+C2:C+D2:C)*E2:E)))
But that just makes all the values to sum of all of what the individual values should be...so, in my example, it works out to 435 (60 + 135 + 240).
What am I doing wrong here? The values in column 5 should be different in each row (e.g., row 2 should be 135 and row 3 should be 240).
Thanks!
use:
=ARRAYFORMULA(IF(ISBLANK(E2:E)=TRUE,, (B2:B+C2:C+D2:D)*E2:E))
SUM is not supported under AF

Sum Offset from MS Excel to Google Spreadsheet

I've made an excel document from MS2013 (xlsx) that computes all numbers above it, because i want it to dynamically compute and adjust its own formula as i add more rows above it. But when i import this on google spreadsheets, the formula doesn't work anymore. here is the sample and formula
A B C D
1 3 3 2 2
2 4 3 4 5
3 5 6 4 3
4
5 12 12 10 10
the formula for A5 is =SUM(A1:OFFSET(A5,-1,0))
when i add 1 more row above A5 the formula adjusts accordingly to the formula's current position. What's the correct formula for google spreadsheet?
I propose you this formula (it's certainly not the better solution, nevertheless it's a solution):
=sum(indirect("A1:"&ADDRESS(ROW()-1;COLUMN())))
You can use this in your example:
=SUM(A1:A4)
If you start adding extra rows, then they will be automatically accounted for.

Resources