Creating Google Sheets pivot tables with custom formula - google-sheets

I am creating table for finance: will have a data base of trades: date open and close for trade (), open and close prices, ticket is a stock name, change is percentage which is calculated base on open-close price and days are also calculated base on two dates as on the picture:
And I need to generate a new table for each month of the year (in which I have date records). So, Google sheets has Pivot tables and that what I need. I need columns: average win % per month, average loss % per month, average number of win days per month, average number of loss days per month.
I did that in 2 separate tables:
First table:
First table settings:
Second table:
Second table settings:
But I can not create that in one table - I do not know how to make custom formula. So, I am looking for some help here.
I tried some things, I can filter, make average. But I do not know how to get array of items with sorted pivot table data by months...If I can get sorted pivot table data by months - I can filter by positive/negative and find average.
My sample: https://docs.google.com/spreadsheets/d/1TCLWZ7-oUSwM8DLODPpH6wwssgfYyo3BVlEpWj78kV4/edit?usp=sharing

Related

Calculate a percentage for subtotals in a Pivot Table - Google Sheets

I have a pivot table that is pulling in quarterly sales data and splitting it up by lead source. I want to calculate the percentage of leads brought in by each person as compared to the subtotal of jobs per quarter.
The problem I am running into is I cannot figure out how to get the subtotal as a number in my calculated field. The equation is simple- total leads per lead source divided by total number of leads. But because I have the pivot table split up by lead source, I cannot get the subtotal to calculate.
In my screenshot, you will see the "% of Total Jobs" column looking correct in the 2021-Q4 category. This is because I just did the Calculated field as "=counta(Project)/16." This is what I want it to look like dynamically for each quarter, with the "16" being replaced with whatever the subtotal of that quarter is. For instance, for Q3, that number should be 14.
The solution might be right under my nose and I'm not thinking of it.
Google Sheets screenshot of pivot table
Thank you!

Google Sheets formula help - total the number of X in a specific data range from another sheet

I have a spreadsheet with multiple pages. on page one i have a chart with row values of months and column values of different subjects.
i would like to have a formula that supplies a live update of all instances of X in a specific data range on page one and the data on page two. (ie: total number of times "Apple" is listed in column B for the month of august, date in column A).
of note: data is added to the top of this sheet every day, so the cells need to be dynamic
thank you for your assistance.

Average instead of Sum in Grand Total of Pivot Table in Google Sheets

In Google Sheets, is there any way that the "Grand Total" of a column in a Pivot Table is something different than the values of the column represents? (for instance, in a sum column, show the average).
An example would be in a sheet with daily sales of several products. You want in the column for each product to show the yearly sales (sum column), but the grand total to show the average of the values in the column.
This is very easy to do in Excel, since you can configure the Grand Total to be other function. I have not been able to find the same functionality in Google Sheets.
Edit: Original question was badly formulated.
Though it reads Grand Total, the presented result depends on the choices you make on Summarise by as clearly seen in the image.
In our example for Days the Grand Total is the average of all days.
For Points the Grand Total is the minimum of all points

Calculating rows that match a month in the header

I'm trying to calculate the monthly totals for fruit that I record sales of weekly.
I have a table that records the above data.
I would like another table that calculates the SUM values for each month for that fruit. Because every month has a potentially different number of weeks, I need a formula to essentially cycle through the weeks for the particular fruit I'm interested in and SUM the values for that month dynamically.
I've tried a bunch of different things, like:
=IF(A3:A5="Banana", SUM(INDEX(C2:J2,,MATCH("January",C3:F3))))
...in the hopes that I could somehow:
Search for a fruit in a table
If found, run through the weeks and
calculate monthly values
Spreadsheet here
In B9 try this formula
=sum(filter(filter($C$3:$5, month($C$2:$2)=column()-1), $A$3:$A$5=$A9))
Fill down and to the right as far as needed.

SUMIF/SUMPRODUCT match multiple criteria within date range

I have a table (Sales) data that has two sets of columns with code, amounts and date reference:
And I have another table (Sheet1):
which need to sum the total net amount with one set subtract the other set on the Sales table but it have to matched the code and based on the weekly date range in Sheet1 table. I can sum the total amount together but I can't separate it with date.
Try:
=SUMIFS(Sales!I:I,Sales!F:F,$A4,Sales!G:G,$C4,Sales!H:H,">="&Sheet1!D$1,Sales!H:H,"<="&Sheet1!D$2)
IF you want the difference between the sum of the blues and the sum of the reds subject to the same conditions, repeat the above (with adjustments to suit) at the beginning and link the two together with a -.
I've work this one out. This is my formula:
=SUMPRODUCT(--(Sales!$C$1:$C$1000>=$C$1),--(Sales!$C$1:$C$1000<=$C$2),--(Sales!$A$1:$A$1000=A4),Sales!$D$1:$D$1000)-SUMPRODUCT(--(Sales!$H$1:$H$1000>=$C$1),--(Sales!$H$1:$H$1000<=$C$2),--(Sales!$A$1:$A$1000=A4),Sales!$I$1:$I$1000)

Resources