Calculate a value for a column in a WebGrid - asp.net

I'm trying to calculate a column value using two properties of the DataSource.
This is my column:
grid.Column(header:"Duration", format:#<text>#{((TimeSpan)(item.EndTime - item.StartTime)).TotalMilliseconds}</text>)))
I keep getting an HTTPCompileException when I try to navigate to this grid. Why is it unhappy with this?

Needed to remove the {} from the format block.

Related

Calculating database cell value

My issue is to calculate the division of one column and another column and to return it to new column in the database.
So each one of the cell in one column should be divided with cell that is next to her in other column.
How can I do that?
So in this picture every element of column "izmerenavrednost" and every element of column "ciljanavrednost" should give element in column "ocenavrednosti"
column"izmerenavrednost"/ column"ciljanavrednost"=column"ocenavrednost"
This would help
Update table
set ocenavrednost = ifnull(izmerenavrednost ,0.00)/ ifnull( ciljanavrednost ),0.00)
If I understand correctly, this is what you are after?
UPDATE table
SET ocenavrednost = izmerenavrednost / ciljanavrednost
If you wanted to subtract instead, then it would be this query:
UPDATE table
SET ocenavrednost = izmerenavrednost - ciljanavrednost

BIRT report: dynamically adding columns to a table based on dataset data

In my report, a table is displaying results from a dataset and it has 6 columns.
But sometimes the dataset returns more than 6 columns depending on the report parameters.
So I need a way to dynamically add columns to my table
Thanks
I'd do it the other way round.
The number of the columns in the query is fixed anyway (for example: FIXED_A, FIXED_B, DYNCOL01, ..., DYNCOL20).
In the layout, your table should have columns for all columns (FIXED_A to DYN_COL20).
Clear the table's width. Set a fixed width for the fixed columns (with enough room left for the dynamic columns). Clear the width of all dynamic columns.
From now on, do not resize and column with the mouse, because this would set individual widths for each column again.
In your table properties, add aggregate bindings for each DYN_COLnn using the MAXIMUM function (let's call these MAX_COL01, ..., MAX_COL20).
For each columns, use a visibility expression like this (the number matching the layout column to the query column accordingly), e.g. for the first dynamic column:
!!row["MAX_COL01"]]
The !! means basically: interprete this as boolean, so the result is: show this column only if MAX_COL01 is not null - or in other words: if DYN_COL1 is not empty in any of the rows.

BIRT, How to get Dataset Row Count using Javascript

How can I get Dataset Row Count from Javascript function in BIRT. I tried searching this in BIRT exchange, but the only solution offered there is to have a new dataset getting count of values of required data set. This wont suit my needs.
Is there any way to obtain it using dataset events.
An easy way would be to count dataset items in a report variable.
Declare a new variable in your report outline:
Reset it in beforeOpen script of the dataset (in case this dataset is invoked multiple times during report execution):
vars["items"]=0;
Increment the variable in onFetch script of the dataset:
vars["items"]++;
Use your variable in any expression. For example add a dynamic text element in report's body such:
"Items count="+vars["items"]
Important 1: This approach works if and only if the dataset is bound to at least one report element (a table, chart, data element, etc.). For example, it won't work if the dataset is only invoked to fill a list of selection choices of a report parameter.
Important 2: In the body of the report, this variable can only be used after the first report element using the relevant dataset, otherwise it won't be initialized
Dominique has a great answer; It is not clear to me from your question if this simpler solution might also meet your needs.
In your data set use a computed column with a value of '1', then sum the values.
You can write JS that only adds the value if specific criteria are met.
Or you can use an aggregation on your report to sum the values, which would be after any filters or groups are placed.
There is a simpler way if you use the row number in your tables footer:
In the 'Dynamic Text' element you can select:
Avilable Column Bindings > Table > RowNum
Add 1 as the index starts with 0.
You could also make a variable and then add to that for each row created in a table.
For example, in the Table-Detail script, set an onCreate event to check for a value in each row and if there is one to increase the row count. The following onCreate script would check if the row is empty. If the row is not empty, the script increases the counter and goes to the next row.
var checker = this.getRowData().getExpressionCount();
if( checker > 0 ) vars["Counter"]++;
Then you could add dynamic text after the table with the following expression:
"Row count="+vars["Counter"]

How to make RDLC report two column

I have a simple report which is supposed to be used for printing stickers. The sticker paper is A4 size and it has two columns. I successfully managed to print data to left column. I also want to print data to right column too. My current report looks like this :
[Title]
[NameLastName]
[Address]
How can I make my report to fill data to two columns? Thanks.
EDIT :
I have generated another column as suggested in other questions. But the result is still one column, Can anyone tell me the next step?
The simplest way to do it [I think] is to:
add additional "columnNumber" column and make it "1" for, say, all odd rows and "2" for all even rows.
then place two tables side by side and make the same DataSetName property for both of them
then filter the data in each table based on the columnNumber Value (add Filter to Filters property of the table)

Not able to add new column to datable from computing other column values

I am trying to add column to datatable whose value is derived from some mathematical computations on other columns. I am doing as below:
dt.Columns.Add("OpeningBalance", GetType(Decimal), "Amt01-" + "Amt02-amt03")
What I need is to subtract amt03 to Amt02 and get absolute value of that. And then subtract that value from Amt01 and get result as non-negative(getting absolute.
I tried using Math.abs, but I am not sure how to exactly embed that inside this.
It should be like this :
math.abs (Amt01 - math.abs(Amt02-amt03))

Resources