Rank column with arrayformula and cull duplicates based on another column - google-sheets

I'm struggling with a Google Sheets arrayformula. I want to make an arrayformula to show rank position of Column B values (TOT). With my formula I just achieve a copy of the first position. I don't want duplicate values in the rank, so if there is two equal values the Column A sets the priority.
={"POS";ARRAYFORMULA(IF($B2$B:$B<>"";RANK.EQ(B3;B3:B42;0)))}
Test Document:
https://docs.google.com/spreadsheets/d/1qzs1nvpzG0VgygxbXF9bKxvGaAq-H29oI1aquupYNFc/edit?usp=sharing

If you put this in cell C2, it will rank them as you're trying to do. If you wanted to match the other direction (lowest to highest), then swith the sort parameter from false to true.
=Filter(match(B2:B+(A2:A/1000),
Sort(Filter(B2:B+A2:A/1000,B2:B<>""),1,false),0),A2:A<>"")
You also appear to have duplicates including in column A (example see rows 4,25,35). If you wanted to exclude the duplicates (effectively reducing the number of ranked values), This can be done using the unique function which would create a 17 in each row.
=Filter(match(B2:B+(A2:A/1000),
Unique(Sort(Filter(B2:B+A2:A/1000,B2:B<>""),1,false),0)),A2:A<>"")

Related

list all unique values and count how many times each appears

A spreadsheet contains multiple rows and columns with names (in varying order), the same name can appear in multiple places, but not necessarily in the same column or row.
Looking to list all names and count the number of times each name appears (no duplicates).
Tried the UNIQUE in combination with COUNTIF, but I can't seem to make them work together. :(
I'm sure there's some way of nesting formulas to tabulate the results, but I just can't wrap my head around it.
You can select your whole range in a query like this (change A2:F with your desired range)
=QUERY(FLATTEN(A2:F),"SELECT Col1,COUNT(Col1) where Col1 is not null group by Col1")
See this answer on how to stack unique counts when values are in multiple columns.
For example if your data is in A1:D10:
=UNIQUE({A1:A10;B1:B10;C1:C10;D1:D10})
Will return a (vertical) list of all unique values. Then use countif in a new column on the whole range (rows, columns) with condition on each of the unique values.

Automatically fill sum column

I have a table of items with its buying and selling rates. Against each transaction, I wanted to show the item qty currently available and the current cost. Here is a screenshot of the table.
For the columns of Qty and Rate, I have used the formulas as shown below:
=SUMPRODUCT(C$2:C-F$2:F,B$2:B=B2,A$2:A<=A2)
=SUMPRODUCT(I$2:I/J2,B$2:B=B2,A$2:A<=A2)
Is it possible to convert SUMPRODUCT formulas as an array formula (returning array) so that it automatically fills whenever a row is added? Something like filling a column using FILTER or QUERY?
Regards,
Pravin Kumar.
I am making an assumption that this is your goal:
To automatically fill the quantity remaining column with the result of the difference between the two values, if and only if, there are two values provided.
A solution to this objective is:
=arrayformula(if(and(C2:C<>””, F2:F<>””), C2:C-F2:F, “”))
This produces a formula that subtracts C from F only if both C and F have values, and for all rows that have values in both C and F. If one of the rows does not have a value, the result will yield “” (blank). This formula should be posted at the top of the column where you want these results to start. In your screenshot example this would be cell J2. NOTE: 0 is still a value, and also that an array formula will not overwrite manually input data, so once you paste that function in J2, you will have to clear the cells below in order for it to auto populate.

How to use IF AND statement with range of cells google sheets

I'm trying to sum cell values based on an two adjacent cell values to help me organize/visualize my investment portfolio activity. I want to sum only the values in the cells under column B if the accompanying cell in column C and D meet a certain requirement.
Basically, for the values in B2:B1000, take the values for B(n) where C(n) equals "Deposit" and D(n) is equal to "Robinhood" and sum them. Below is a screenshot indicating the cells within column B that I want summed (in red) based on the criteria that meets both conditions. The below logic should give you the sum $1100.
I tried to at least check if C(n) equals Deposit with this line but then it just sums all of the values in column B.
=SUM(IF(C2:C1000=G2, B2:B1000, 0))
My guess is some of the cells in column C meet the condition it sums all of column B. That's the first problem. The second problem is I can't introduce the second condition without creating some sort of error.
My specific case is happening on google sheets.
Answer
Use SUMIFS(): =SUMIFS(B:B,C:C,"Deposit",D:D,"Robinhood")

Google Sheet Formula How to find UNIQUE Data Through Column Reference

Image of formula not working
I am trying to filter data by column reference
Not Work For Me =UNIQUE(A2:C6)
What i want it shoutd be like What actually i want
I want find UNIQUE Data Through Column Reference B is Mo No.
Solution
In this case a simple UNIQUE statement is not enough. You are looking for a function that takes in account only one column for your uniqueness check.
In this case SORTN is best suited for this job.
=SORTN(A1:C7,7,2,2,1)
Here is how it works:
n: The number of items to return. Must be greater than 0.
I have 7 rows so at most 7 results
display_ties_mode: A number representing the way to display ties.
In this case 2: Show at most the first n(7) rows after removing duplicate rows.
sort_column1: The index of the column in range or a range outside of range containing the values to sort by.
In this case is 2 as well. Since the uniqueness check is performed in the B Column.
is_ascending: TRUE or FALSE indicating whether to sort sort_column in ascending order.
This is up to you

How do I add up the value of column B if column A meets a certain condition for each value in column A with one formula?

Below is an example of the values I'm trying to add. My goal is not to use the filter formula for every line again. This is because it takes a lot of resources from the processing power that google sheets uses.
The words in the left list below occur several times in combination with a certain number. I want to have a unique list as shown on the right where the values from the left row add up when the words are equal (without using a filter formula for each line).
This formula
=arrayformula(vlookup(A:A, A:B, 2, FALSE)))
comes very close, but returns only one value even though there are multiple matches. I want all values that matches returned.
try:
=QUERY(A:B, "select A,sum(B) where A is not null group by A label sum(B)'summed'", 1)

Resources