How to obtain average values on columns filter

pankajgrover

Board Regular
Joined
Oct 27, 2022
Messages
157
Office Version
  1. 2021
Platform
  1. Windows
Here below example data : where results are coming in 3 columns: Particluar, Qty , Average
I want to formula check D8 Col. BUY/SELL filter, and displayed results like Particluar, Buy Qty , Buy Average, Sell Qty , Sell Average,
How to edit my formulas to displayed this results : Particluar, Buy Qty , Buy Average, Sell Qty , Sell Average
Shares Search Filter APPLE.xlsx
ABCDEFGIJL
1Advanced Search Bar - All Column Search
2
3
4
5Unique Stocks Average
6189Average2013.07380470.60
7DateParticularQtyBuy/SellPriceTotalsParticularQtyAVG
806/08/2024 MICROSOFT25BUY135.703392.501 MICROSOFT664346.09
906/08/2024 SAMSUNG5BUY643.503217.501 SAMSUNG101430.08
1006/08/2024 NETFLIX11BUY3347.7036824.701 NETFLIX361578.67
1106/08/2024 APPLE50BUY287.0014350.001 APPLE77292.16
1206/08/2024 MICROSOFT5SELL49899.90249499.501  
1306/08/2024 APPLE25BUY287.807195.001  
1406/08/2024 MICROSOFT11BUY1610.6517717.151  
1506/08/2024 SAMSUNG4BUY2651.6010606.401  
1605/08/2024 APPLE1SELL475.50475.501  
1705/08/2024 MICROSOFT25BUY649.3016232.501  
1805/08/2024 SAMSUNG1BUY476.85476.851  
1904/08/2024 NETFLIX25BUY800.3020007.501  
2004/08/2024 APPLE1SELL475.50475.501  
search_bar
Cell Formulas
RangeFormula
C6,F6C6=SUBTOTAL(9,C8:C1000)
E6E6=F6/C6
A8:F20A8=FILTER(my_data,NOT(ISERROR(SEARCH(A1,my_data[Particular]))),"")
I8:I11I8=FILTER(UNIQUE($B$8:$B$1000),UNIQUE($B$8:$B$1000)<>0)
J8J8=SUMIFS($C$8:$C$1000,$B$8:$B$1000,I8,$G$8:$G$1000,1)
L8:L20L8=IFERROR(K8/J8, "")
J9:J20J9=SUMIFS($C$8:$C$1000,$B$8:$B$1000,I9)
G8:G20G8=SUBTOTAL(103,A8)
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A8:F1000Celldoes not contain a blank value textNO
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Like this perhaps?

ABCDEFGHIJKLM
1Advanced Search Bar - All Column Search
2
3
4
5Unique Stocks Average
6189Average2,013.07380,470.60BuyBuySellSell
7DateParticularQtyBuy/SellPriceTotalsParticularQtyAVGQtyAVG
86 Aug 2024 MICROSOFT25BUY135.703,392.50 MICROSOFT61612.17549,899.90
96 Aug 2024 SAMSUNG5BUY643.503,217.50 SAMSUNG101,430.080-
106 Aug 2024 NETFLIX11BUY3,347.7036,824.70 NETFLIX361,578.670-
116 Aug 2024 APPLE50BUY287.0014,350.00 APPLE75287.272475.5
126 Aug 2024 MICROSOFT5SELL49,899.90249,499.50
136 Aug 2024 APPLE25BUY287.807,195.00
146 Aug 2024 MICROSOFT11BUY1,610.6517,717.15
156 Aug 2024 SAMSUNG4BUY2,651.6010,606.40
165 Aug 2024 APPLE1SELL475.50475.50
175 Aug 2024 MICROSOFT25BUY649.3016,232.50
185 Aug 2024 SAMSUNG1BUY476.85476.85
194 Aug 2024 NETFLIX25BUY800.3020,007.50
204 Aug 2024 APPLE1SELL475.50475.50
21
Sheet1
Cell Formulas
RangeFormula
C6,F6C6=SUBTOTAL(9,C8:C20)
E6E6=F6/C6
I8:I11I8=LET(u,UNIQUE($B$8:$B$20),FILTER(u,u<>0))
J8:J11,L8:L11J8=BYROW($I8#,LAMBDA(r,SUMIFS($C$8:$C$20,$D$8:$D$20,J$6,$B$8:$B$20,r)))
K8:K11,M8:M11K8=IFERROR(BYROW($I8#,LAMBDA(r,SUMIFS($F$8:$F$20,$D$8:$D$20,K$6,$B$8:$B$20,r)))/J8#,"-")
Dynamic array formulas.
 
Upvote 0
With power query
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Particular", type text}, {"Qty", Int64.Type}, {"Buy/Sell", type text}, {"Price", type number}, {"Totals", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Particular", "Buy/Sell"}, {{"Total", each List.Sum([Qty]), type nullable number}, {"Average", each List.Average([Price]), type nullable number}})
in
    #"Grouped Rows"

Book6
ABCDEFGHIJK
2DateParticularQtyBuy/SellPriceTotalsParticularBuy/SellTotalAverage
345510 MICROSOFT25BUY135.73392.5 MICROSOFTBUY61798.55
445510 SAMSUNG5BUY643.53217.5 SAMSUNGBUY101257.316667
545510 NETFLIX11BUY3347.736824.7 NETFLIXBUY362074
645510 APPLE50BUY28714350 APPLEBUY75287.4
745510 MICROSOFT5SELL49899.9249499.5 MICROSOFTSELL549899.9
845510 APPLE25BUY287.87195 APPLESELL2475.5
945510 MICROSOFT11BUY1610.6517717.15
1045510 SAMSUNG4BUY2651.610606.4
1145509 APPLE1SELL475.5475.5
1245509 MICROSOFT25BUY649.316232.5
1345509 SAMSUNG1BUY476.85476.85
1445508 NETFLIX25BUY800.320007.5
1545508 APPLE1SELL475.5475.5
Sheet1
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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