I am trying to fix an error in googlesheet especially related to Pivot table. Especially when I make extra calculations from the Pivot table I get the #Div error when I filter on basis of few parameters. But if I make it without any filters I do get proper results.
I am looking for a solution where the calculations can take particular cell values with respect to cell column name only. So I can make a better calculations without any type of filters or shiftings. This is a dynamic case.
Can anyone suggest any better answer?
https://docs.google.com/spreadsheets/d/1h1TdFLj3JyK6-oxOOswuWDx4YixzG51H2rWgK0BbD2s/edit#gid=925622507
#DIV error is the result of trying to divide an empty cell with another empty cell
it's a standard issue equivalent to dividing 0 with 0. such math is not logical and google sheets will flag it as an error to alert you.
however, the true culprit is that #REF error:
filters of pivot table cant produce/create additional columns. pivot table will just roll out data wherever it needs. in your scenario pivot table attempts to roll out date into 3 columns but only two columns there are empty. 3rd column (C) is filled with data/formulae and pivot table cannot move data or delete data so if there is no space to roll out it will #REF error to alert you that something went wrong.
possible solution: move C, D columns to the right. if you are not able to predict how many columns will filter of pivot data roll out into then have som extra space between and for the visuals you can hide those empty columns
Related
I need to filter rows of a pivot table that have no value in 2 columns. E.g. if rows are people and columns are fruits, I need to filter people who have no apples or pears (but may have other fruits).
I've tried to add a custom formula filter on the "filter" part of the pivot tables, but it is either not working or I'm not getting the syntax right. I'm not sure where I'm supposed to be pointing towards.
This is an example formula I would want to use in my pivot table filter:
=NOT(AND(ISBLANK(E4); (N4=0)))
I can have a workaround to this if I filter the actual columns of the sheet, as seen here, but that also filters the rest of the rows of the sheet, outside the pivot table which I do not want
The current formula is:
=averageifs(index(data,,match(B5,Headers,)),index(data,,match("position 1",Headers,)),B3)
The function averages total weight for specific positions. It goes through my data sheet's headers to find the column titled "position 1" to find all the athlete who play position B3, but I have athlete who play multiple positions and want to have them included as well.
Is it possible to get it to search through multiple column to find all the athletes who play the same position?
Headers named range
data named range
This gets a bit complex, but I think it will give you what you need. It does change the formula from the AVERAGEIFS to the QUERY function.
=QUERY(data,"select avg("&LEFT(ADDRESS(Headers,MATCH(B5,Headers,0),4),1)&") where C='"&B3&"' or D='"&B3&"' or E='"&B3&"' or F='"&B3&"' or G='"&B3&"' or H='"&B3&"' or I='"&B3&"' or J='"&B3&"' or K='"&B3&"' or L='"&B3&"' or M='"&B3&"' label avg("&LEFT(ADDRESS(Headers,MATCH(B5,Headers,0),4),1)&") ''")
I believe the only thing you may need to change is deleting some of the comparisons to columns. I wasn't quite sure how many Position columns you have in your original sheet.
I have a function in a data validation drop down list that shows options from a range A2:A30, but I only want it to show options that have a value greater than or equal to 10 in the column over B2:B30. The cell I am referring to is O5.
Example sheet
The purpose/objective is that I have a linear regression formula building projections based on past data about the selected mode, and I don't want the dropdown to be able to select options that have a count less than 10 (because the projection is wildly inaccurate). I would like to do this without creating a second tab or hidden section that populates a second range under those conditions, and then rerouting the data validation to that range.
Any suggestions towards this goal or towards learning about the general idea will be appreciated.
I have come to an indirect solution by manipulating the data in a different way specific to my example sheet. I changed the data validation drop-down range from A2:A30 to A2:A5, and then changed the =unique() formula to a query that fill in the options, the count for that option, and then sorts it ascending so that the top spots are the ones with the most data. Therefore the linear regression will be somewhat limited to the options with better data.
The query is:
=query('Data Sheet'!$A$2:$C, "select A, count(A) where A is not null group by A order by count(A) desc label count(A) ''")
All of the rest of the formulas are built off of that query, including the data validation drop down. It is in my example sheet.
I'm creating a Google Sheet documenting how many times a certain item appears in a video game with the formula in the D column (formatted to a percent):
=IFERROR(C2/SUM(C2:C51))
I want the "C2" cell to apply down the column (C3, then C4, you get the idea), but I want the "C2:C51" array to stay constant while the C2 part gets applied down the down the column. How could I modify the formula to do this? (I could manually edit the formulas all the way down, I only have 50 rows, but I think it would be helpful to learn for the future)
Try this:
=iferror(C2 / sum(C$2:C$51))
See absolute and relative references.
Alternatively, try this array formula that fills a whole column in one go:
=arrayformula(iferror(C2:C51 / sum(C2:C51)))
I have a big sheet with quite a lot of info that keeps growing over time. Based on that, I have created several pivot tables that do some calculations and rankings.
Every ranking keeps growing, so pivot tables may contain 10 rows now, but can grow up to 20 or 30 rows.
I managed to insert several pivot tables in the same sheet and now it looks well, with every ranking after the next one. However, if I add multiple rows, the pivot tables grow and start overlapping, so after a while the ones below start disappearing in favour of the first ones.
Is there a way to have multiple pivot tables in the same sheet with a fixed number of rows among them, preventing them from overlapping?
If you want to 'play' with the data, I created a sample in https://docs.google.com/spreadsheets/d/1MVX3tp6GIqVX6hTyk6TsCxV7YngiMpi7E8oSxa7a9ck/edit?usp=sharing. It is just a ranking on races, where I want to track the best times on different legs. Then it has a second sheet 'rankings' in which I have different pivot tables, one for each leg.
HOw's this for a single formula solution that will scale infinitely in users or legs:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(results!A2:A&"|Best of "&results!D1:1&"|"&OFFSET(results!D2,,,ROWS(results!D2:D),COLUMNS(results!D1:1))),"|",0,0),"Select Col2,Col1,MIN(Col3) where Col1<>'' and Col2<>'Best of ' group by Col1,Col2 order by Col2, MIN(Col3) label MIN(Col3)'Best', Col1'User',Col2''"))
You'll find it in cell B1 on the new tab in your sample called MK.Idea
I should mention that FLATTEN() is an undocumented function that I only recently discovered. I've believe it is intended to remain "hidden" in the back end of the sheets programming, but if what I did is what you're after, there really isn't a more efficient way to do it. I've spoken with an engineer at Google who was surprised it existed as well and told me there were no plans to deprecate it, so here's hoping! For a demo of what it does generally, you can see my sample here:
https://docs.google.com/spreadsheets/d/196NDPUZ-p2sPiiiYlYsJeHD6F_eJq7CWO_hP7rFqGpc/edit?usp=sharing
Spreadsheets and Pivot Tables are marvelous tools for data analysis but they aren't too friendly for creating reports and dashboards, if you are open, to recommendations try Google Data Studio (it includes pivot tables too --> https://support.google.com/datastudio/answer/7516660?hl=en)
Let say that you don't have time to learn another app or you just prefer to keep using spreadsheets, in this case it will be required to implement a workaround.
First, bear in mind that Pivot Tables don't actually overlap, instead an error message is shown:
Solution: insert some rows/columns to give enough room to the Pivot Table to be expanded.
NOTE: You could do this in advance by including a "safe zone" (meaning blank rows /columns) around the pivot tables. You could hide/unhide this "safe zone" as needed.
If you don't want to do the above manually, I think that it should be possible to use an on edit trigger of Google Apps Script to detect that pivot tables are shown and insert new rows/columns to avoid this. If the Pivot Table top left cell returns #REF! your script could use a do.. while or a while to insert the required rows or columns. An smart algorithm will read the Pivot Table settings to calculate the required rows and columns and then insert the required rows / columns in one pass.
Related
Pivot table with Google Script