As I'm using angular ui-grid, I'm looking for a way to get sum of rows.
Basically I have a timesheet model grid where users will clock their work logs. The last column will show the total number of hours worked per week. This will be the sum of row items. How do we do this?
All examples lead to column aggregates but now row.
Thanks
You can always add a column at last, specify a template for the cell, and inside the template you will have access to row.entity, write a function that takes the row as input, traverses it for all 'keys' and sums them up, returns the summation. Call the function from the template, so in each angular 'tick' you will get updated values.
Related
Note: tried in Excel and Google Sheets, but I have a preference for Sheets.
Basically I want to get the sum of a group of data using INDEX and MATCH (because the parameters are going to be drop-down dependent):
The desired result is:
So this will require a few things:
Converting the cell D13(April) to a Month
Converting the "weekof" column to a Month
Using INDEX and MATCH and MATCH again, I'm assuming because it's multiple cell references.
Here's my solution currently below:
=SUM(INDEX(D5:I9, MATCH(MONTH(D13&1),ARRAYFORMULA(MONTH(C5:C9)),0), MATCH(E12,D4:I4,0)))
This returns the NEAREST value:
270
Instead of:
804
Why this value?
270+500+34 = 804
If you are not strict to use INDEX and MATCH, you may use the following solution:
Add extra column name it "Month", this column will extract the month name from the date column using TEXT function as the following:
=IF(C3<>"",TEXT(C3,"mmmm"),"")
The if statements ensures that only filled dates will have a month value, since you have to fill this column with the above formula for a certain amount of cells.
Now you can simply use the SUMIF function in cell E13 or where ever you want:
=SUMIF(B:B,D13,D:D)
If you don't want the Month column to appear within your data table you may put it at the end of your table and hide it.
You could directly use FILTER then SUM the result instead to simplify your formula to this one:
Formula:
=SUM(FILTER(D:D, TEXT(C:C,"MMMM") = E13))
Output:
UPDATE:
The above formula should also update when the value is dropdown. Dropdown is just data that can be changed with predetermined values, aside from that, it should be the same when using a normal cell.
To match columns, use MATCH and INDEX together with the formula above. See modified formula below.
Be careful of the circular dependency. make sure your ranges doesn't interfere with the actual cell where you put your formula.
Column Matching:
=SUM(INDEX(FILTER(D:E, TEXT(C:C, "MMMM") = E13),,MATCH(F12, D4:4, 0)))
You can use pivot table and group dates by year and month.
I am using ag-grid to display data. There are two tabs for current data and archived data. Above the grid for both tabs, in the title bar, there is a filter that filters the free text. The label of that filter shows the filtered rows/total number of rows.
In the archived tab, there is an additional filter that selects the data from past months. The filtered row count gets bigger than the actual number of rows when you quickly switch to:
Last Year
Last 6 Months
Last 3 Months
and then switch between tabs.
I think it is the in memory row model that is causing this issue.
I tried these two to get filtered rows
this.selectedRows = this.gridOptions.api.getModel().getRowCount();
this.selectedRows = this.gridOptions.api.getModel().rootNode.childrenAfterFilter.length;
I was just wondering is there any other way of doing it without using the in memory row model. Any help would be greatly appreciated.
Thanks a lot.
For future reference:
The code below is fine.
this.selectedRows = this.gridOptions.api.getModel().getRowCount();
The were some timing issues and I fixed this with resetting the row data by
this.gridOptions.api.setRowData([]);
this.gridOptions.api.setRowData(data);
I'm using jqGrid with AngularJS to make a small web.
I have created a grid with some data, using jqGrid grouping including a summary row.
I've changed summary row position to the main row of each group.
I want some summary cells that have to be averages rounded to 2 decimals, but I don't get it working.
This is the colModel definition for one of the rows which I want to round:
{name:'cost', label:'Total Cost', width:55, summaryType:'avg',summaryRound:2, summaryRoundType:'round'}
How can I get that column rounded?
You forgot to add formatter:'number' in the colModel...
Please, take more time to do some research before asking next time.
i am using extJs paging tool bar with store or grid panel ,it works fine with records .
when if there are no records in database,and after receive jsson data.it does,nt display proper number of records which will be zero .please give me solution
You must have the total number of rows calculated in the controller part, to have a result as this one:
{success:true,"total":1,"result":[{"id":"2","MyColumn1":"blabla","MyColumn2":"blibli"}]}
Where total is number of rows
Can you give us your code and the json result that it's given to your store
I have applied Top N filter on 'Purchase_Amount' group so that i can get only Top N values of group but when i am applying Sum on group
=Sum(Fields!Purchase.Value, "Purchase_Amount")
that give me sum of
whole dataset so how can i get sum of filtered group ?
You could try setting the filter on your tablix instead of the group - any sums in the tablix are then subject to that filter.
There are many ways to address this. I would probable move the filter up the data stream, either into the query, or into the Dataset properties.
But some two other methods are described in this MSDN Community thread:
Either creating a fake total row within the group members that contains the =RunningValue(...) function, and set the visibility to only show on the last row; or refer to another page item where you can get just the total of your filtered items.