I am trying to use an array to highlight specific rows in my data.
As shown in the picture, i want to extract the maximum positive profit($) and maximum negative profit($) for each respective serial numbers and highlight it in yellow. For example, Tom123's maximum +ve profit = 100 and -ve profit =-74 , thus both values are highlighted in yellow.
I already know how to highlight cells in vba, but i do not know how to get the rows that i need to highlight. Any help is much appreciated.
Add a column to identify if the column C = max profit or max loss
step 1
In D2, write =IF(OR(C2=MAX(IF((A:A=A2)*(C:C>=0),C:C,"")),C2=MIN(IF((A:A=A2)*(C:C<0),C:C,""))),TRUE,"") then press ctrl+shift+enter.
step 2
drag D2 down.
then you will see:
step 3
highlight A:C if D == true with conditional formatting
Related
I'm trying to create a calculated field that displays the growth rate in % from one of the numeric columns in my pivot table.
How can I reference a row above the current cell to calculate the growth rate?
=(Current cell - (Current cell - 1 Row)) / (Current cell - 1 Row)
Pivot table
Year
Count
Calculated Field (YoY Growth)
2019
100
2020
300
100%
2021
600
50%
based on instructions:
=(Current cell - (Current cell - 1 Row)) / Current cell
={""; ARRAYFORMULA(IFERROR(B2:B-(B2:B-B1:B999)/B2:B))}
I agree with player0, that seeing your sheet, data, data types and layout would facilitate helping you.
However, I'll venture a solution, sight unseen.
There are actually many ways to address what I think you're asking. This is just one of them.
Suppose that your source numbers are in range A2:A. Place the following formula in some other open column, in the cell parallel to the top number in your source range:
=ArrayFormula(ARRAY_CONSTRAIN({"";FILTER(({A3:A;""}-A2:A)/{A3:A;""},A2:A<>"")},COUNTA(A2:A),1))
I've added in more "parts" than are probably necessary. But I tried to include controls, seeing as I don't know what your data actually looks like.
An alternative is to place the following simpler formula into the cell one below where the top number in your source range is:
=ArrayFormula(IF(A3:A="",,(A3:A - A2:A)/A3:A))
In either case, you'll want to format the column/range where the results will be as percent (Format > Number > Percent).
Obviously, if your source numbers are in a range other than A2:A, you'll need to adjust the ranges in either formula accordingly.
This is hard to explain so my title sucks, and is just my best guess at how I might be able to approach this. I have a Google Sheet of sales data for cases of various bottle sizes of kombucha. Column E is the sale date, Column G contains the item code, and column J is the quantity sold of said cases. See my (vastly simplified) sample data:
https://docs.google.com/spreadsheets/d/17-LzGrNJtBr-FwOZtdaoCws3ayeGOHu_TdtGOfXj4cA/edit?usp=sharing
See my current test code below (also present in the Formula tab of the linked spreadsheet). It successfully gives me the combined number of cases sold of half-liter bottles and Growlers. The values in E4 and E5 are cells containing my start and end dates, respectively, so I'm constraining the results only to those which fall within a certain date range.
This code works, but now I need to figure out a way to sum the total number of bottles sold instead of # of cases. The data set is already massive and pushing the limits of google sheets, so adding a column to the source data sheet with # of bottles per case is not an option. Half liter cases hold 13 bottles, and growlers hold 5. Is there any way to do this with my current approach, using another array perhaps? Or any other approach that keeps the formula as simple as possible?
FYI the current formula is a proof of concept and I will be adding many additional types of cases to the existing formula, each containing a different number of bottles per case, and using it as part of a larger dynamic formula that allows you to switch between showing # cases vs # bottles vs # of actual liters sold, so this is why I am hoping to find an array-based approach that will let me do this without needing to resort to an absurdly long and complex formula of nested IF statements.
=SUMPRODUCT(--((XeroInvoiceData!$E$3:$E>=B4)*(XeroInvoiceData!$E$3:$E<=B5)), (--(ISNUMBER(MATCH(XeroInvoiceData!$G$3:$G, {"HalfLiterCase","GrowlerCase"}, 0)))), XeroInvoiceData!$J$3:$J)
I would be eternally grateful for any assistance.
Here is my solution:
https://docs.google.com/spreadsheets/d/1ig0krumJu4Lj9-nIKJyRfPLTYbU-mzOL0JokRUDEqNc/edit?usp=sharing
My idea was to filter your table on date and sum by the type of container.
I wanted also to allow new types of containers that contain smaller units (bottles or liters).
I divided this job into 3 stages.
First we have to filter this table according to selected dates and container types.
I prepared a list that may be extended (all you need is to extend the filter range).
Then I have to vlookup values of units in each container and I try to do it inside the same formula.
General idea is
={[query results],arrayformula(ifna(vlookup([first column of query],$C$21:$D$26,2,0)*[second column of query])}
I divide it into 2 stages.
First stage referrs to query results in adjacent table:
Second stage uses indexes of query so formula is quite long:
Tell me if it solves your problem.
If 15 is the lowest number and 200 the highest number, what formula do I need to use to define a multiplication pattern that applies the 28 values needed to complete this multiplication table?
I would like to learn how to create this pattern to use, I tried it
through percentages but I was not successful exactly because it had
the minimum and the maximum, if it was only the minimum or only the
maximum, just multiply it by the percentage.
if you want to paste those values in the same column you need to do:
then the formula will be:
=ARRAYFORMULA(INDIRECT("A"&
MAX(IF(A3:A<>"", ROW(A3:A), )))+SORT(ROW(INDIRECT("A1:A"&
MAX(IF(A3:A<>"", ROW(A3:A), ))-2)), 1, 0)*(A1-INDIRECT("A"&
MAX(IF(A3:A<>"", ROW(A3:A), ))))/(
MAX(IF(A3:A<>"", ROW(A3:A), ))-1))
Try this formula in A2 =$A1+($A$30-$A$1)/29 and then drag down to A29
I have a spreadsheet document that I want to make as efficient as possible. It is used to calculate the quantity-based discounts of a product. The more you buy, the cheaper the unit is.
https://docs.google.com/spreadsheets/d/1JxrvA3WPANQeIXqLt-7NFFgyxxKbqr_4rW_Q5ptAvKA/edit?usp=sharing
In the first red cell, call "tiers" I will input the quantities at which the discounts will be applied.
I want to use this array in the table directly underneath, one item per row until we run out of numbers.
I will then enter the percentage values in the right hand side and that will then populate the rest of the fields.
So all I will need to do is enter the cost price, the tiers, and the percentages and this calculator does the rest.
My question is, how do I create new rows based on this array in the correct place?
paste in B10 cell and drag down:
=B$9-B$9*C10
paste in B15 cell:
=ARRAYFORMULA(IFERROR(A15:A*VLOOKUP(A15:A, A9:B12, 2)))
spreadsheet demo
I have been working on a large data set of lab testing results (previously you all have been helpful but I have a new wrinkle). Each sample has 3 columns in excel(concentration, Qualifier, MDL) and Column A has about 167 chemicals that could possible be screened for. Not all samples were screened for all chemicals, so some of the samples may have blank rows. In column B is a benchmark value that the concentration should not be greater than. I need to do the following 3 things, which i think are somewhat related. 1) Count of samples tested for a chemical, 2) Count of samples with concentrations greater than benchmark with a qualifier <>"U", and 3) Count of samples with concentrations greater than benchmark with a qualifier ="U". See above for how the results should look.
Previously, I had used an aggregate function (Suggested by you guys) to get a max and minimum for samples with a qualifier of u and without - but i can't see a way to do a count using the aggregate function.
Assuming that you meant great than, and not great than or equal to your bench mark, the following three formulas should work for your sample data. It is based on the assumption that a blank concentration means a sample was not tested.
The following counts non blank concentrations:
=SUM(--(F2<>""),--(I2<>""),--(L2<>""))
The following counts concentration greater than the bench mark and no U qualifier:
=SUM(--(AND(F2>B2,G2<>"U")),--(AND(I2>B2,J2<>"U")),--(AND(L2>B2,M2<>"U")))
The following counts concentrations greater than the bench mark and with a U qualifier:
=SUM(--(AND(F2>B2,G2="U")),--(AND(I2>B2,J2="U")),--(AND(L2>B2,M2="U")))
The above formulas are based on the chemical sitting in row 2. copy down as needed.
Note the -- in the formula above simply change the TRUE or FALSE results to an integer 1 or 0 respectively. This can also be achieved using any math operation that does not change the value such as *1 or +0.
OPTION 2
Counting With SUMPRODUCT
Again this will be on the assumption that if the concentration is empty/blank then no sample was tested for that row/chemical. Since the need is to count instead of looking for a max and min, I am opting to use SUMPRODUCT. Like AGGREGATE, it performs array like operations without actually being an array.
The following counts non blank concentrations:
=SUMPRODUCT(($F$1:$N$1="Conc")*($F2:$N2<>""))
The following counts concentration greater than the bench mark and no U qualifier:
=SUMPRODUCT(($F$1:$N$1="Conc")*($F2:$N2>$B2)*($G$1:$O$1="Q")*($G2:$O2<>"U"))
The following counts concentrations greater than the bench mark and with a U qualifier:
=SUMPRODUCT(($F$1:$N$1="Conc")*($F2:$N2>$B2)*($G$1:$O$1="Q")*($G2:$O2="U"))
The above formulas are based on the chemical sitting in row 2. copy down as needed.
Note the shift in range when checking for header Q and the value U