Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 months ago.
Improve this question
I am trying to do a formula for:
NUMBER OF SHARES per sector - should count all shares from column E:E in column I:I based on sector
TABLE:
SYMBOL
NAME
TYPE
SECTOR
OWNED SHARES
SHARES PRICE
SECTOR
NUMBER OF SHARES
TOTAL PER SECTOR
TYPE
TOTAL PER STOCK TYPE
ABML
American Battery Technology Co
Growth
-
100
79
-
Growth
BABA
Alibaba Group Holding Ltd - ADR
Growth
Consumer Cyclical
200
12574
Consumer Cyclical
Dividend
BAC
Alibaba Group Holding Ltd - ADR
Dividend
Financial
1000
35460
Financial
LI
Li Auto Inc
Growth
Consumer Cyclical
300
4791
Energy
MMP
Magellan Midstream Partners, L.P.
Dividend
Energy
10000
515700
MPLX
MPLX LP
Dividend
Energy
20000
662000
DEMO
https://docs.google.com/spreadsheets/d/1sBVb29p0yYcn3-CI3TvG6noN8AQPE2zxDCKojUcb2Nw/edit?usp=sharing
Thank you
I tried
=sumif(D:D; H2; F:F) it works, but I wanted this function to be repeated for every value in column H once there is a new value.
Here is your formula for I2, then copy it down however far you need it:
=SUMIF(D:D,$H2,E:E)
Here is your formula for J2, then copy it down however far you need it:
=SUMIF(D:D,$H2,F:F)
And finally, your formula for M2, then copy it down however far you need it:
=SUMIF(C:C, $L2,F:F)
You may as well try:
Number of shares:
=SUMIFS($E$2:$E$7,$D$2:$D$7,$H$2:$H$7)
Total per Sector:
=SUMIFS($F$2:$F$7,$D$2:$D$7,$H$2:$H$7)
Total per Stock type:
=SUMIF(C:C, $L2, F:F)
On all three scenarios you need to drag down the formula for it to display the results.
Related
Above is an example of data in Google Sheets. The green table is to keep track my purchases and the red table is to show the inventory summary.
I am stuck at creating a formula to calculate the Balance Stock Cost.
The Balance Stock Cost should only sum up the cost of unsold quantity from latest received date.
For example, for SKU A, the stock balance is 31 units. The purchases of SKU A sorted by received date will become like this...
Since the stock balance is 31, the formula should sum up the purchases on 10-Jan (5 units x 6), 7-Jan (25 units x 4) and 5-Jan (1 unit x 5.5) which brings the total to 135.5.
Please help me to come up a formula to calculate the Balance Stock Cost based on above requirements. Thanks.
You can try:
=MAP(A18:A,D18:D,LAMBDA(ax,dx,IF(ax="",,SUM(QUERY(SORT(ARRAYFORMULA(split(flatten(A2:A15&"|"&B2:B15&"|"&D2:D15&"|"&MAP(C2:C15,LAMBDA(cx,TRANSPOSE(SEQUENCE(cx,1,1,0))))),"|",0,0)),1,1,2,0),"Select Col3 Where Col4 is NOT NULL AND Col1='"&ax&"' LIMIT "&dx)))))
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 months ago.
Improve this question
I am working on a school rooming timetable system. I am finding a formula which finds if a particular room is used during a specific period by which class and teacher.
There is a staff overview with clean data of which class and room they are in, alongside preferred results:
https://docs.google.com/spreadsheets/d/1H9Q8K9KBLgqCsvVZ_ekqsLPbZKeMzvldDnyI-KerOD4/edit?usp=sharing
For example, for on the overview, Monday Period 1 (Column B) Staff 1 uses room BG01 for the class 07MA01. Thus on the room overview, it shows that in Period 1, Staff 1 uses BG01 for 07MA01.
Use filter() and regexmatch(), like this:
=iferror(
textjoin( "; ", true,
filter(
regexreplace('Staff Overview'!B$3:B, "#.+", "") & "(" & trim('Staff Overview'!$A$3:$A) & ")",
regexmatch('Staff Overview'!B$3:B, $A3)
)
),
"FREE"
)
This question already has answers here:
Repeat whole row N times based on column value in Google Sheets
(2 answers)
How to Repeat a Data Set (several columns) x times in Google Sheets [duplicate]
(1 answer)
Repeat range of items multiple times in Google Sheets
(5 answers)
Closed 5 months ago.
I need to create a weighted lottery where people can have multiple entries and the number of entries is based upon a series of questions. For each question they get right, they get an entry into the lottery.
In my head, I've got a table with the participants' names and their total number of points (entries), then I need some way to have a list of the names with their multiple entries. So if my initial table looked like this:
Name
Points
John
5
Larry
4
Andre
2
Mika
6
Then my output list would look like this:
Name
John
John
John
John
John
Larry
Larry
Larry
Larry
Andre
Andre
Mika
Mika
Mika
Mika
Mika
Mika
Then I could just use the default row leaders from the output table as the entry for the person and use a random number generator to pick numbers.
That being said, I'm open to other ideas.
Try this formula-
=QUERY(INDEX(FLATTEN(SPLIT(REPT(A1:A4&"#",B1:B4),"#"))),"where Col1 is not null")
REPT(A1:A4&"#",B1:B4) will repeat each cell value of A1:A4 as per number in B1:B4. Then Split and flatten with make them a vertical array (column). Query() will return all the values except nulls (if any).
To make it more dynamic you may try-
=QUERY(INDEX(FLATTEN(SPLIT(REPT(A1:INDEX(A1:A,COUNTA(A1:A))&"#",B1:INDEX(B1:B,COUNTA(A1:A))),"#"))),"where Col1 is not null")
And with new LAMBDA() functions.
=FLATTEN(SPLIT(JOIN("",BYROW(A1:INDEX(B1:B,COUNTA(A1:A)),LAMBDA(x,REPT(INDEX(x,1,1)&"|",INDEX(x,1,2))))),"|"))
This is my computatiom sheet: (https://docs.google.com/spreadsheets/d/e/2PACX-1vSR3jhKH7FNfuqo_VcemDUoZGNtoUJttCQz8XF0r7c8Qyyc4PWQqqHyxanalb5etA/pubhtml?gid=6282745&single=true)
Name Country Region Unique Region Region Count Sales Representative
Mr Action Taker Dubai EMEA EMEA 5 Eashwari
Mr Responsible Bangalore APAC APAC 7 Chetan
Mr Careful guy Mumbai APAC AMER 3 Khushi
The unique region is computed by UNIQUE function which is giving me the list of unique regions from the inputs that i receive one by one. If a new region is added, the unique list will be appended automatically.
The region count is the count of regions in my input. I have use the MOD function to assign the lead to a sales rep in a chronological fashion so that even distribution is achieved.
In the above sheet, my region count increases by 1 as soon as a new entry is added into the input sheet. When that happens, a sales rep is assigned automatically.
Each region has 4 sales rep.
Now, i have an output sheet below. (https://docs.google.com/spreadsheets/d/e/2PACX-1vSR3jhKH7FNfuqo_VcemDUoZGNtoUJttCQz8XF0r7c8Qyyc4PWQqqHyxanalb5etA/pubhtml?gid=1954161251&single=true)
Name of the Lead Team Sales Representative Notes:
Mr Action Taker EMEA We want to upgrade our subscription
Now, I want to show the sales rep in the output sheet which i have computed in the computation sheet. This shall not change if my computation sheet is updated whenever new entry comes in.
The sales rep shall be from his region team.
use:
=INDEX(IFNA(VLOOKUP(A2:A&" "&B2:B, {
IMPORTRANGE("url_or_id_of_spreadsheet", "Part 2 Computation Sheet!A2:A")&" "&
IMPORTRANGE("url_or_id_of_spreadsheet", "Part 2 Computation Sheet!C2:C"),
IMPORTRANGE("url_or_id_of_spreadsheet", "Part 2 Computation Sheet!F2:F")}, 2, 0)))
I have 2 sheets in Google Sheets:
All contacts w. week/month/year, where we pull all of our deals for the year
Weekly Marketing analytics, where we match up all of this information on a weekly basis
In the Weekly Marketing analytics, every column from B2 to BB2 is a week number (1-53), and A1 is the current year (2021 with this sheet).
I am currently trying to find and sum, every deal value on a 10 week running average (week 1-10, 2-11 etc.) and in order to do that, I've created this formula:
=SUMIFS('All contacts w. week/month/year'!$D:$D;'All contacts w. week/month/year'!$T:$T;$A$1;'All contacts w. week/month/year'!$Q:$Q;C$2:L$2; 'All contacts w. week/month/year'!$E:$E; "ORGANIC_SEARCH")
'All contacts w. week/month/year'!$D:$D - This is the column with all of the revenue for a given deal.
'All contacts w. week/month/year'!$T:$T;$A$1 - This is the column with the year of the deal.
'All contacts w. week/month/year'!$Q:$Q;B$2:K$2 - This is the column I am having trouble with. This is the column with the week number of the deal, and since I am doing a 10 week running average, I want every deal for the last 10 weeks. So all deals from week 1, 2, 3 etc that matches all of the other criteria.
'All contacts w. week/month/year'!$E:$E; "ORGANIC_SEARCH" - This is the last criteria, defining which marketing channel the deal originated from.
Currently this formula returns 0, despite there being a deal in week 4, and I cant work out why the system is missing it?
In the bigger picture, this is the for I want to end out with:
=IF(SUM(C$116:L$116)>0;SUM(SUM(C$143:L$143)/SUMIFS('All contacts w. week/month/year'!$D:$D;'All contacts w. week/month/year'!$T:$T;$A$1;'All contacts w. week/month/year'!$Q:$Q;C$2:L$2; 'All contacts w. week/month/year'!$E:$E; "ORGANIC_SEARCH")); 0)
Quickly checking if there is any deals counted in those weeks, if yes then sum up the marketing cost for a given channel, divided with the revenue of the deals for those given weeks.
It's hard to say without seeing the actual data, but it looks like the Criteria2 argument is problematic, because C$2:L$2 is really an array of criteria. So depending on your version of Excel, it would return either a spilled array or the first element of the array (basically only using C$2 as a criteria.)
If the week numbers are numeric (1,2,3 etc.) instead of text (Week1, Week2, Week3, etc.) then you ought to be able to break it out into 2 criteria using inequalities. For example, suppose L2 is week 11. That means the expression L2-9 provides your lower bound of 2. So in your SUMIFS function you should sum everything greater than or equal to L2-9 AND less than or equal to L2.
Your formula might look something like this:
=SUMIFS('All contacts w. week/month/year'!$D:$D;'All contacts w. week/month/year'!$T:$T;$A$1;'All contacts w. week/month/year'!$Q:$Q;">=" & L2-9; 'All contacts w. week/month/year'!$Q:$Q; "<=" & L2; 'All contacts w. week/month/year'!$E:$E; "ORGANIC_SEARCH")