How to get sum of a column at last page of active reports - activereports

I have a active report that has two column named Deposit and Withdrawal.I want to get sum of both the columns at last page of active report. I have done some code in ReportStart event
var fldDepositTotal = ar.Sections["gfDetail"].Controls["fldDepositTotal"] as DataDynamics.ActiveReports.TextBox;
var fldWithdrawalTotal = ar.Sections["gfDetail"].Controls["fldWithdrawalTotal"] as DataDynamics.ActiveReports.TextBox;
fldDepositTotal.DataField = "AmountD"; // Your datafield value
fldDepositTotal.SummaryFunc = SummaryFunc.Sum;
fldDepositTotal.SummaryGroup = "ghDetail";
fldDepositTotal.SummaryRunning = SummaryRunning.Group;
fldDepositTotal.SummaryType = SummaryType.GrandTotal;
fldWithdrawalTotal.DataField = "AmountW"; // Your datafield value
fldWithdrawalTotal.SummaryFunc = SummaryFunc.Sum;
fldWithdrawalTotal.SummaryGroup = "ghDetail";
fldWithdrawalTotal.SummaryRunning = SummaryRunning.Group;
fldWithdrawalTotal.SummaryType = SummaryType.GrandTotal;
I have make it in report footer also but still not getting sum of Deposit and Withdrawal amount. How can I get sum of columns?

The SummaryRunning setting basically defines when to reset the accumulating total back to zero. In the case of a grand total value at the report level you don't want the value to be reset - you want it to continue accumulating throughout the entire report. So you don't need the SummaryGroup and SummaryRunning properties here. So based on the sample in the SummaryType property's documentation you can set the SummaryGroup and SummaryRunning properties as follows:
fldDepositTotal.DataField = "AmountD";
fldDepositTotal.SummaryFunc = SummaryFunc.Sum;
fldDepositTotal.SummaryGroup = null;
fldDepositTotal.SummaryRunning = SummaryRunning.None;
fldDepositTotal.SummaryType = SummaryType.GrandTotal;

Related

Bulk copy filtered rows from one google sheet to another google sheet

I have a spreadsheet where I am able to filter the sheet based on a value on a column. I can copy the filtered data using isRowHiddenByFilter. But this does it one row at a time. I am looking for some input on how I can copy say 200 rows that I obtain after using a filter to be copied to another spreadsheet all at once and not evaluating 200 rows.
This is what I have working:
var criteria = SpreadsheetApp.newFilterCriteria().whenTextContains("I do NOT
plan").build();
ss.getActiveSheet().getFilter().setColumnFilterCriteria(4,criteria);
var nrsheet = ss.getSheetByName("Not Returning");
for (var i = 2; i < sheet.getLastRow(); i++)
{
if(!sheet.isRowHiddenByFilter(i))
{
row_data = sheet.getRange(i, 1, 1, sheet.getLastColumn()).getValues();
one_arr_nr = row_data.join().split(",");
nrsheet.appendRow(one_arr_nr);
}
}
This is what I would like to do:
Remove the for loop to evaluate each row and be able to copy what I see on the spreadsheet to be copied to the Not Returning sheet. Any help on how I can proceed?

Sum a field on UITable based on the value on dropdown

I am creating an app which will perform some simple mathematical functions. One of these functions is to sum the field on my table. However, it should sum the field based on what is selected on the drop down menu and display the sum value on an edit field component. For instance, using the attached image, when I click control total, I would like to display the sum of the numbers in the fiscal period column and display it on the edit field on the right called sum.
function ControlTotalButtonPushed(app, event)
ct = app.FieldsDropDown.Value;
total = sum(app.UITable.Data.ct);
app.EditFieldTotal.Value = total;
if total == 0
app.BalanceUnbalanceLabel.Text = 'Balance';
else
app.BalanceUnbalanceLabel.Text = 'Unbalance';
end
end
I get an error:
Unrecognized variable name 'ct'
I thought app.UITable.Data.ct would refer to the column name to sum?
Please refer to the attached picture.

Printing the calculated distance in SQLAlchemy

I am using Flask-SQLAlchemy with Postgres, Postgis and GEOAlchemy. I am able to sort entries in a table according to a point submitted by the user. I wonder how I could also return the calculated distance...
This is how I sort the items:
result = Event.query.order_by(func.ST_Distance(Event.address_gps, coordinates_point)).paginate(page, 10).items
for result in results:
result_dict = result.to_dict()
return result_dict
according to the users position (coordinates_point). I would like to add an entry in each result in the result_dict which also contains the distance that the item was ordered by. How do I do that? What does func.ST_Distance return?
I tried to add this in the for loop above:
current_distance = func.ST_Distance(Event.address_gps, coordinates_point)
result_dict['distance'] = current_distance
But that did not seem to work.
You can use column labels
query = Event.query.with_entities(Event, func.ST_Distance(Event.address_gps, coordinates_point).label('distance')).order_by('distance')
results = query.paginate(page, 10).items
for result in results:
event = result.Event
distance = result.distance
result_dict = event.to_dict()
result_dict['distance'] = distance

Getting the total number of records in PagedList

The datagrid that I use on the client is based on SQL row number; it also requires a total number of pages for its paging. I also use the PagedList on the server.
SQL Profiler shows that the PagedList makes 2 db calls - the first to get the total number of records and the second to get the current page. The thing is that I can't find a way to extract that total number of records from the PagedList. Therefore, currently I have to make an extra call to get that total which creates 3 calls in total for each request, 2 of which are absolutely identical. I understand that I probably won't be able to rid of the call to get the totals but I hate to call it twice. Here is an extract from my code, I'd really appreciate any help in this:
var t = from c in myDb.MyTypes.Filter<MyType>(filterXml) select c;
response.Total = t.Count(); // my first call to get the total
double d = uiRowNumber / uiRecordsPerPage;
int page = (int)Math.Ceiling(d) + 1;
var q = from c in myDb.MyTypes.Filter<MyType>(filterXml).OrderBy(someOrderString)
select new ReturnType
{
Something = c.Something
};
response.Items = q.ToPagedList(page, uiRecordsPerPage);
PagedList has a .TotalItemCount property which reflects the total number of records in the set (not the number in a particular page). Thus response.Items.TotalItemCount should do the trick.

set Datagirdviewcombobox column value in Vb.net

I have datagrid with two datagridviewcombo column, one column is dynamic fill and one has fixed hardcoded values.
The problem is I can't set the value of dynamic GridViewComboBox, when I try to set it generates continues errors.
System.FormateException: DataGridViewComboBoxCell Value is not valid.
My code to load the grid is
Dim dt As DataTable
dt = GetDataTable("Select valuecol,displayCol From mytable") 'GetDataTable gives me datatable
cmbAntibiotics.DataSource = dt
cmbAntibiotics.DisplayMember = "Antibiotics"
cmbAntibiotics.ValueMember = "AntibioticsID"
Dim Index As Integer
Dim dgr As DataGridViewRow
For Each dr As DataRow In dtFromDB.Rows 'This datatable is filled with database
Index = dtFromDB.Rows.Count - 1
GRDAntimicrobials.Rows.Add()
GRDAntimicrobials.Rows(Index).Cells("cmbAntibiotics").Value = dr("AntibioticsID").ToString 'At this point it shows value (1,2,3) rather then showing its display members
GRDAntimicrobials.Rows(Index).Cells("AntibioticsStatus").Value = dr("AntibioticsStatus").ToString
Next
Pls help with me
It seems like you're trying to assign the value to whatever there is on the cell rather than instantiate the object that resides in the cell and then assign its value. I would try something like this:
Dim vComboBoxColumn As DropDownList = DirectCast(GRDAntimicrobials.Rows(index).Cells("cmbAntibiotics"))
vComboBoxColumn.Value = dr("AntibioticsStatus").ToString