Phill032

Board Regular
Joined
Nov 9, 2016
Messages
51
Hi All, any help on this would be greatly appreciated.
The data below refers to a Used car stocklist advertising changes. Each line represents a log of a price change on the internet.
I need the following data retrieved from this list.
1 - Total number of internet changes for each car
2 - The Date of the last previous change
3 - The amount of the last previous change
4 - Total Price change variance

Stock#Value BeforeValue AfterLog Date
1234013,88801/03/2019
123413,88813,94503/03/2019
123413,94513,94006/03/2019
1235015,99004/03/2019
123515,99016,58006/03/2019
123516,58016,69007/03/2019

<tbody>
</tbody>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi Phil,

Can you use this?


Book1
ABCDEFG
2Stock#Value BeforeValue AfterLog Date
31234013,88801-03-19
4123413,88813,94503-03-19
5123413,94513,94006-03-19
61235015,99004-03-19
7123515,99016,58006-03-19
8123516,58016,69007-03-19
9
10StockInternet Changes #Date of Last ChangeAmount of LastMinMax%
111234306-03-1913,94013,88813,9450.4%
121235307-03-1916,69015,99016,6904.2%
Sheet1
Cell Formulas
RangeFormula
A11=INDEX($A$3:$A$8,MATCH(0,INDEX(COUNTIF($A$10:A10,$A$3:$A$8),),0))
B11=COUNTIFS($A$3:$A$8,A11,$D$3:$D$8,">0")
D11=SUMPRODUCT(($A$3:$A$8=A11)*($D$3:$D$8=C11)*$C$3:$C$8)
G11=(F11-E11)/F11
C11{=MAX(IF($A$3:$A$8=A11,$D$3:$D$8))}
E11{=MIN(IF($A$3:$A$8=A11,$C$3:$C$8))}
F11{=MAX(IF($A$3:$A$8=A11,$C$3:$C$8))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Thanks, Almost works perfectly.. only the previous price change amount is not the last amount is is the second last amount.
So for stock# 1234 the value would be 13,945. other than that it seems to work perfectly
 
Upvote 0
like this?

with PowerQuery (Get&Transform)

Stock#Value BeforeValue AfterLog DateStock#ChangesLastDate LastAmount Min Max %
1234​
0​
13,888​
01/03/2019​
1234​
3​
06/03/2019​
13,945​
13,888​
13,945​
0.41%​
1234​
13,888​
13,945​
03/03/2019​
1235​
3​
07/03/2019​
16,690​
15,990​
16,690​
4.19%​
1234​
13,945​
13,940​
06/03/2019​
1235​
0​
15,990​
04/03/2019​
1235​
15,990​
16,580​
06/03/2019​
1235​
16,580​
16,690​
07/03/2019​

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table14"]}[Content],
    Sort = Table.Sort(Source,{{"Value After", Order.Ascending}}),
    Date = Table.TransformColumnTypes(Sort,{{"Stock#", Int64.Type}, {"Value Before", Int64.Type}, {"Value After", Int64.Type}, {"Log Date", type date}}),
    Group = Table.Group(Date, {"Stock#"}, {{"Changes", each Table.RowCount(_), type number}, {"LastDate", each List.Max([Log Date]), type date}, {"LastAmount", each List.Max([Value After]), type number}, {"Min", each List.Min([Value After]), type number}, {"Max", each List.Max([Value After]), type number}}),
    Percent = Table.AddColumn(Group, "%", each ([Max]-[Min])/[Max])
in
    Percent[/SIZE]
 
Last edited:
Upvote 0
but imho it should be like in post#2

Stock#ChangesLastDate LastAmount Min Max %
1234​
3​
06/03/2019​
13940​
13,888​
13,945​
0.41%​
1235​
3​
07/03/2019​
16690​
15,990​
16,690​
4.19%​
 
Upvote 0
ok so maybe im just not catching on here.. The code you have attached looks to me like VBA, post 2 i just typed up as normal formulas.
Can i just past your code? The data i supplied is only a small extract of the data in my worksheet.
 
Upvote 0
M-code (PowerQuery) has nothing to do with vba

that's why I asked about your excel version...

Excel 2010/2013 free PowerQuery add-in
Excel 2016 and higher PowerQuery (Get&Transform) is built-in

edit:
I need to go now, will be later
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,369
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top