I've created a results page for a board game we play. We enter the results on the Last Game sheet. I then click Save Results which inserts rows and copies the result data accordingly into three sheets, Game Totals, Player 1 and Player 2.
The Last Game sheet has number of wins, averages and such which all use formulas, e.g.
=COUNTIF('Game Totals'!D2:D164, "SUSAN")
D1 is a header row. The latest results are copied into the inserted row, D2.
My problem is while I want D164 to increment to D165 in the formula above I want D2 to remain as D2, but it increments to D3.
I read up a little on using $D$2 but that doesn't stop it from incrementing to D3.
Any help most gratefully appreciated
Cheers
Johnny.
Assuming that cell 'Game Totals'!D1 does not equal Susan and does not move when you insert rows, you can start the range reference from that cell:
=countif('Game Totals'!D1:D164, "SUSAN")
Related
I want to get the total leaf node row count in AgGrid when row grouping and text filter are activated.
I used the gridApi.getDisplayedRowCount() method but it returned the only number of groups that are displayed in the table.
I can't use the row-data count either, since the text filter filters out some data.
Let me know if there is any way to get the leaf node count in such a scenario.
Cheers 😀
Can someone please help?
I have a Google Sheet and as soon as I open the file I need to show a pop-up message displaying the total of blank cells in column M. I do not need to write the value in the sheet. I simply need the script code to do the calculation and show the quantity of empty cells in the message box. Also, I need the code to start counting from M3 and as far as the last row containing data in column M (it needs to find that last row automatically).
I've tried the following, but obviously is not working, it's far from working:
function alertMessage() {
var Formula = "=COUNTBLANK(M3:M)";
var result = SpreadsheetApp.getUi().alert("Empty cells total:" &Formula);
if(result === SpreadsheetApp.getUi().Button.OK) {
}
}
Thank you so much.
Here's an example image before I start explaining:
Let's say I have these entries from a Form (A2 to D6). Let's also say I want to find the average of ONLY the values that were submitted with "Tier 1" and "Type 2" in the same row. How would I approach writing a script that could do that?
I can elaborate more if needed. Any help is appreciated :)
Here is some algorithm plus code in jquery
1) Get all the rows in your table. You will have an array of all the table rows.
var rows = $('#tblID > tbody > tr')
2) Now loop through your array of rows with a for loop. Lots of example are available on the web. Here is one way
for (i=0;i<rows.length;i++){
var row =rows[i];
}
3) For each row inspect the column you are interested in. If they match then get the column with the number and add it to your sum and increment how many you will be averaging on. Here is snippit of how you get a column in plain js
var column = row.cells[3];
Keep in mind that the column is node, not the text in that node yet, so you will need a jquery call to get the text likes so
var stuff = $(column).text();
I am working on table that is built dynamically depending on filters chosen. I currently am able to sort by any row that I click. The problem is I need the first row that I sort by to stay when I click on another row, so that the second row I click is sorted within the means of the first row. An example I have two columns, first name and last name.
**FirstName** **LastName**
Bob Zimmer
Bob Anderson
Kathy Walege
Kathy Ball
So say I click on the first name row. It will stay the same since the first names are already in order. But when I click on the Last Name row I want the following to happen.
**FirstName** **LastName**
Bob Anderson
Bob Zimmer
Kathy Ball
Kathy Walege
I currently have it working so it only sorts by one column at a time. I am using both javascript and vb.net to get this to work with my code.
Here's the javascript:
function SortColumn(col)
{
__doPostBack('SortBy',col);
}
Here's the vb function that calls the javascript function:
Private Function AddSortLinkToColumn(ByVal sSortColumn As String) As String
Dim sVal As String = ""
sVal = "<a href=""javascript:SortColumn('" & sSortColumn & "');""><font face=""Webdings"">"
If m_sSort <> "" AndAlso Split(m_sSort, "-")(0) = sSortColumn AndAlso m_sSortDrxn = "ASC" Then
sVal &= "5"
Else
sVal &= "6"
End If
sVal &= "</font></a>"
Return sVal
End Function
This is currently taking the column that is being clicked and matching it up with my global sort variable. If they match it displays an up arrow. If it fails it displays a down arrow.
I know that I need to somehow keep track of the first column that was clicked, but I am not sure how to do so. I have tried it on the vb.net side and javascript sides by adding another column to the sort but it doesn't do me any good if I can't get the first column value to stay!
How can I keep the first column's sort and then sort by the second column as well? Any help would be greatly appreciated!
UPDATE
With the help of the answer listed below I finally got this working! Here's the code:
function SortColumn(col)
{
<% if m_sSort = nothing then %>
__doPostBack('SortBy', col);
<% else %>
__doPostBack('SortBy', document.getElementById("SortField").value + "," + col);
<% end if %>
}
The m_sSort was a public variable on the vb.net side. The "SortField" was the name of the hidden field where the m_sSort value was being stored.
Add a hidden field to the page called prevCol or something like that. Since it is a hidden field it will be posted back with the form.
In your postBack event handler, make sure to consume that hidden field and replace its value with the currently clicked column.
In this way you will have the column that is clicked as well as the column that was previously clicked. If you check the value and it is empty you know you are starting off.
Your remove sort button would then clear the prevCol field to ensure that you are starting fresh.
So your flow would look like this:
First column click: prevCol is empty so you sort by the currently clicked column and write its identifier to the prevCol field on the
returned page.
Second column Click: prevCol now has a value. So first sort by that value, then sort by the supplied column. Make sure you write the
supplied column to prevCol in the return.
Xth column Click: Same as second click. Inherintly this is going to make the prevCol the first column that is sorted each time.
When you click your remove sort button, ensure you are not writing a value to prevCol and thus starting the cycle over.
In this way you are kind of caching your previous column on the client with each response so that it is always present during post back.
EDIT:
I thought it would be simple to alternatively do this entirely on the client side with jQuery as long as the server did not need to know the order of the rows.
So I spent some time thinking about how this would be done using jQuery and I found it was a bit more challenging than I originally anticipated.
with some help from James Padolsey I was able to easily sort the table rows, but the logic of sorting based on the previous column was a bit strange.
This is what I ended up with.
Say I use a table to display scheduled content, and I want rows to disappear after their date has passed.
Row 1 has Table title
Row 2 has Date A
Row 3 has Scheduled content A1
Row 4 has Scheduled content A2
Row 5 has Date B
Row 6 has Scheduled content B1
Row 7 has Scheduled content B2
Row 5 has Date C
Row 6 has Scheduled content C1
Row 7 has Scheduled content C2
etc.
After Date A has passed, I want rows 2-4 to disappear/be hidden.
I do this website on a volunteer basis, and there is nobody else available to help. I delete the expired rows on a daily basis, but I'm going on vacation and will be unplugged for two weeks.
I don't have any example code, I'm a rookie. If you mean my html code, it's just a simple table.
Sorry for not responding sooner, Jakub (https://stackoverflow.com/users/158014/jakub). Spent 12+ hours in hospital ER with my daughter right after my last edit yesterday. I will come back and fix the post to conform to Stackoverflow standards ASAP.
You can use jQuery library to hide certain parts of the website on certain dates. It should help on this case while you are off.
First load jQuery, adding to the head section of your site:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
Then your table in the body section:
Then, near the end of the body tag, you create a rule for hiding content based on a date:
<script type="text/javascript">
var now = new Date();
var futuretime1 = new Date("April 10, 2013");
if(now > futuretime1)
{
$("#div").hide();
}
</script>
This will hide #div when date passes "futuretime1". You can also use jQuery selectors for selecting the appropriate table row.
Hope this helps.