Excel - Find if a product changed price - excel

How can I find if a product changed it's price in excel? For example:
Yesterday's prices:
Potatoes 5,50
Tomatoes 7.40
Apples 5.60
Cucumber 4.30
Today's prices:
Potatoes 5,50
Tomatoes 5.20
Apples 5.50
Cucumber 4.30
Tomatoes and apples changed their price. How is it possible to highlight those changes based on "A" column product description?

This formula will return TRUE if an item in the list has changed price:
=COUNTIFS($A$1:$A$8,A1,$B$1:$B$8,"<>"&B1)>0
Enter it in C1 (in this example) and drag down

Here is what you can try. I also attached some pics for your reference.
Columns A and B are for yesterday's prices, columns C and D are for today's prices, and column E is to see the price changes (you don't need column E but I just want to show you so you know what is happening). Also, the formula for column E is =INDEX($A$3:$B$7,MATCH($C3,$A$3:$A$7,0),2)-$D3.
To highlight whichever product had price changed. We will use Conditional Formatting which is under Home > Conditional Formatting > New Rule > Use a formula.... Under cell D3, you enter the same formula like in cell E3 which is =INDEX($A$3:$B$7,MATCH($C3,$A$3:$A$7,0),2)-$D3. Pick the color you want as the pic sample below.
Then applies to =$D$3:$D$6 just like the pic shows below.
This should work for you. Try and let me know.

Use the conditional formatting on another column. E.g. have a column of Yesterday-Today and highlight if <> 0.

This will work, use the formula
=IF((AND(A1=C1,B1<>D1)),"yes","no")
where A1, C1 have fruite and B1, D1 have prices.
Below is the result obtained.
Potatoes 5,50 Potatoes 5,50 no
Tomatoes 7.4 Tomatoes 5.2 yes
Apples 5.6 Apples 5.5 yes
Cucumber 4.3 Cucumber 4.3 no
Then you can filter/highlight based on whether it is a yes/no.

Related

How to retrieve Top 2 rows from each group in excel sheet?

The problem is simple to understand. I just need to know a formula that will help find a way to fetch the top 2 rows of each group in an excel sheet.
The below example is grouped by column 1.
Example
Given Table:
Column 1
Column 2
Apple
A102012
Apple
A102013
Apple
A102014
Banana
A102015
Banana
A102016
Banana
A102017
Coconut
A102017
Result:
Column 1
Column 2
Apple
A102012
Apple
A102013
Banana
A102015
Banana
A102016
Coconut
A102017
Try:
Formula in D1:
=REDUCE(A1:B1,UNIQUE(A2:A8),LAMBDA(a,b,VSTACK(a,TAKE(FILTER(A2:B8,A2:A8=b),2))))
To mimic this for Google Sheets:
=REDUCE(A1:B1,UNIQUE(A2:A8),LAMBDA(a,b,{a;QUERY(A2:B8,"Where A='"&b&"' limit 2")}))
A much slower alternative is:
=FILTER(A:B,INDEX(COUNTIFS(A:A,A:A,ROW(A:A),"<="&ROW(A:A)))<3)
A faster method than countifs not using most recent additions to Excel, if it can be assumed that data are pre-sorted:
=LET(count,COUNTA(A:A),Column1,A2:INDEX(A:A,count),Column12,A2:INDEX(B:B,count),FILTER(Column12,SCAN(0,SEQUENCE(count-1),LAMBDA(a,c,IF(c=1,1,IF(INDEX(Column1,c)=INDEX(Column1,c-1),a+1,1))))<=2))
or in Google Sheets:
=ArrayFormula(lambda(Column12,filter(Column12,SCAN(0,SEQUENCE(rows(Column12)),LAMBDA(a,c,IF(c=1,1,IF(INDEX(Column12,c,1)=INDEX(Column12,c-1,1),a+1,1))))<=2))(filter(A2:B,A2:A<>"")))
If you have Excel 365 you can also use this formula
=LET(rank,MAP(tblData[value],tblData[fruit],
LAMBDA(v,f,SUMPRODUCT((tblData[fruit]=f)*(v<tblData[value]))+1)),
FILTER(tblData,rank<=2))
The MAP function calculates the rank of each row within its group.
Then we can filter by that list.

How can I automate these formulas?

Hello,
I need to automate these formula.
Wheat 2 USA minus wheat 1 USA, Wheat 2 Brazil minus wheat 1 Brazil, Wheat 2 Canada minus wheat 1 Canada, Wheat 2 Argentina minus wheat 1 Argentina and so on for every product and taking into account corresponding regions and week numbers.
Barley 2 USA minus barley 1 USA, Barley 2 Brazil minus barley 1 Brazil, Barley 2 Canada minus barley 1 Canada ...
A formula should work in such a way that when I populate it, it understands the logic and make a calculation.
Use LOOKUP to find previous value of current product:
=IFERROR(C2-LOOKUP(2,1/($A$1:A1=A2),$C$1:C1),"")
or so if the Input number column matters:
=IFERROR(C2-LOOKUP(2,1/(($A$1:A1=A2)*($B$1:B1=(B2-1))),$C$1:C1),"")
First: I like #basic's solution much better! I keep forgetting that =LOOKUP(LargerThanAll,Nums,Values) returns the value for the highest num!
That said, here's another way:
First, put your cursor on the top line and Insert - Table, making sure you check the "My table has headers" checkbox in the dialog box that appears.
Now, in addition to having it formatted, there are formula benefits.
Keeping with your example where the B2 = "Product",
Change F2 to "Product|Number" to create a new column
Change F3 to =[#Product]&"|"&[#[Input Number]] (Because you're using tables, you can use column names rather than cell references, [#ColumnName] is the column value for the current row, it will use that formula for the entire column, and the formula is stored once instead of once per row!)
Change G2 to "PrevRow"
Change G3 to =MATCH([#Product]&"|"&([#[Input Number]]-1),[Product|Number],0) (you now have the table row number for the previous value
Change E3 to =IF(ISNUMBER([#PrevRow]),[#Quantity]-INDEX([Quantity],[#PrevRow]),"")
Hide columns F and G. (Or fold their functionality into your Volume's formula so your volume formula doesn't need them and delete them.)

Excel How to insert value based on todays date

I have 4 columns in excel. Date, Apple, Banana and Oranges. I have a different sheet where I have a header called "Today's Production" Under the header I have Banana, Apple and Oranges listed. How do I populate these fields
Screenshot added
If the first cell of your table were in A1, for the bananas column, you can just use something along the lines of
=SUMIFS(B1:B10,A1:A10,TODAY())
Then for apples, you would adjust your B column to C, and for oranges, adjust B to D

Google sheets, adding a value to a cell based on the contents of another

This may be delving in to scripting territory rather than formula, but I was wondering if it's possible to use google sheets to add values to a cell based on the contents of another? For example, If I had a sheet arranged like the following:
Column A|Column B|Column C|Column D
Apples Oranges Grapes
Tomatoes Grapes Oranges
Melons Apples Tomatoes
Grapes Lemons Apples
And then I had another section that had
Column G|Column H
Apples 1
Tomates 2
Oranges 3
Grapes 4
Melons 5
Lemons 6
Is there a formula that will let me populate the contents of column D by reading columns A - C on each row and adding the values set on column H? Making Column D read something like 8, 9, 8 etc?
I hope this question makes sense, thanks and apologies for the shoddy formatting!
=SUMPRODUCT(IFERROR(VLOOKUP(A2:C2,G:H,2,0)))
For google-spreadsheets
Please try this single-formula solution:
=mmult(filter(VLOOKUP(A:C,G:H,2,0),A:A<>""),ArrayFormula(transpose(sign(column(A:C)))))
Paste it in D1.
Here's a sample file of sum with arrayFormula.

Excel SumProduct with if Statement in a cell.

I have a basic problem in Excel. I have a row with names and one with numbers. I try to find what is the sum of these numbers for a special name.
ex.
A B
Apple 12
Apple 12
Kiwi 9
Apple 4
Banana 51
Kiwi 12
Banana 4
Kiwi
So far I just use a basic sumproduct which works well. Like
=Sumproduct((A1:A8=A1)*(B1:B8)
This formula gives me back my total number of Apples
(12+12+4).
The problem is, if a cell contain some formula, then I have #VALUE! result.
Let say the last cell called Kiwi contain a code like
=if(A64="", "", 12)
Then it makes Kiwi empty if A64 is empty. Great.
But sumproduct don't work anymore.
I can't sort the name... any ideas?
Thank you
You can simply use =SUMIF() formula to get sum of these numbers for a special name.
=SUMIF($A$1:$B$64,A1,$B$1:$B$64)
or
=SUMIF($A$1:$B$64,"kiwi",$B$1:$B$64)
You can change these ranges based on your list. (You can even define dynamic name in Name Manager and then you can use that Name as your range.)
It's not the fact that your cell is calculated (contains a formula), it's because the result of the formula is a text.
Maybe you could use à 0 instead of the 0-length text and apply conditional formatting to your cells (font colour white if 0 value)
=if(A64="", 0, 12)

Resources