I have a ultragrid bound to a link data, it displays approximately 100 rows, the rows are like
(columns: rownumber, id, name, amt)
1. 1001 John $10
2. 1002 Bob $13
3. 1003 Kathy $90
1. 1004 David $23
2. 1005 George $84
3. 1006 Eric $83
and the row continues like this with 3 rows as a set.
Now i want the summary of 1's 2's 3's Amt sum like below
Summary:
1= $33
2=$97
3=$173
How can i do this, what formula i can use for this.
i thought so in the beginning to make it as one row and have show it multiple lines, but the stored procedure iam using is a pivot result and it got complicated already, for now i just added another line as a summary row from sql itself, so the grid show like any other row, there is no editing in the grid. and i colored the last row to look like summary row.
thanks for your help and quick responses.
Hi again.
I was just reading your other post about the border after every third row and I had an idea.
It seems to me that if all of your data is in groups of 3s, you could probably make things easier by combining all three rows into a single row of data that displays on 3 lines. It is possible, using RowLayouts, for you to have a single grid row that displays on multiple lines. So you would basically have triple the number of columns in your grid, but 1/3 the number of rows.
This would make your summaries very simple, since you would now be summing three separate columns instead of trying to create 3 summaries for a single column.
It would make it easy for you to do the borders you want, also, since you could simply apply a BorderStyle to the row of a different color or make it a 3d border.
Yes, you would have to do this for every colmun and basically pick out the indices of the rows you wanted to include in the sum.
This would be a lot easier with an ICustomSummaryCalculator, rather than a formula. You create a class that implements the interface and it fires off methods before the summary begins calculating so you can initialize your starting values. Then it fires a method for each row. So you simply ignore the rows you don't want and keep a running total of the ones you do. Then it will fire a method when the summary is done and you pass back your total.
Unfortunately, the row sets are indefinite, could be between 100 to 200.
Even if i build a string formula by calculating individually, do i have to do that for every column, can you give me some example. (Amt column in my first post i given is just an example, i have atleast 25 different amt columns)
I tried the formula like the below:
SUM ( if([rownumber] = 1, [Amt],0) )
but the result are #VALUE, i believe there is a syntax error or may be something else.
Are there a fixed number of row sets? If so and you know exactly how many there are, you could build a formula string that sums up the individual cells. But the formula would have to refer to each cell individually, so it would be a really long string and you would probably want to build the string in code.
If there are an indefinite number of set, then I don't think this is possible. There's no way for a formula to sum a column and only use some rows and not others... at least no built-in way. You could create your own custom function or use an ICustomSummaryCalculator to write code to do the sum yourself.