how to update kendo grid aggregate automatically - kendo-grid

I made a table by kendo grid.
Test column' value is [#: Unitsinstock * Unitprice#].
but,When Unitprice value Changs , test column value
and Unitprice aggregate sum , Test aggregate sum can't update automatically.
Demo:https://dojo.telerik.com/UTOnuN
how to update kendo grid aggregate automatically?
Thx

Related

SSRS access fields in a dataset

I want to write a SSRS expression that will allow me to grab the value from Column B base on the max value from ColumnA.
For Example, I have the following values
ColumnA
ColumnB
1
Test
2
Tester
3
Testing
=FIRST(
iif(
Fields!ColumnA.Value= MAX(Fields!ColumnA.Value,"test"),
Fields!ColumnB.Value,0
),"test"
)
The reason I am doing this is because I am trying to combine to datasets in one table. Certain fields in the table just needs to select top N values from another dataset.
I think that easiest way is to add something like row_number into your sql query (row_number() over (order by ColumnA desc) rn and then you can have condition iif(fields!rn.value = 1, fields!ColumnB.value,0)

How to SUM the values from group in SSRS which are distinct

I have a report where I want to calculate the Grand total but ignore the values of a group which have same value. Below are my tables and the data. The Package No column is grouped and will be unique always, but every unique Package may or may not have same dimensions. I want to SUM the dimension (Length, Width and Height) and it Package No has multiple items in it then have to consider only the first row for summing up the values as the dimensions will remain the same for all the items within the same Package. Can anyone please help me to achieve this result?
Assuming the data that gets returned from your dataset query looks like the sample you show in the image then you should be able to do something like...
=SUM(IIF(Fields!RowNum.Value = 1, Fields!Length.Value, 0))
EDIT after OP update
If the RowNum column is not in your dataset then you will need to add it.
If you dataset query is just a script then it should be as easy as something like this...
SELECT *
, RownN = ROW_NUMBER() OVER(PARTITION BY PackageNo ORDER BY Item)
FROM myTable
If the dataset is the result of a stored proc then you might have to change the dataset query to something like
CREATE TABLE #t (PackageNo varchar(50), Length int, Width int, Height int, Item varchar(50))
INSERT INTO #t
EXEC myStoredProc
SELECT *
, RownN = ROW_NUMBER() OVER(PARTITION BY PackageNo ORDER BY Item)
FROM #t
Once one of the above options are been taken then you should be able to simply apply the =SUM(IIF(Fields!RowN.Value = 1, Fields!Length.Value, 0))
expression in your report totals.

Assigning NO DATA instead showing blank cells in ssrs 2008 - based on row visibility expression

I have a problem in SSRS 2008 described as below:
I have a matrix which is connected to a query, lets say Select * from Table. It is returning, lets say 50 rows of data. In my matrix, there is only one row. Lets say:
id name grade
[id] [name] sum[grade]
The matrix is grouped by 'id' and 'name' in Row Group. There is a row visibility expression for this row like =IIF(sum(Fields!grade.Value)>95,false,true). Assuming that for this situation, this table shows no data, all the returned 50 rows of data has a grade lower than 95 in total. Therefore, I see only the columns without any information on the screen like:
id name grade
What I want is to write "No Data" instead' like:
id name grade
No Data
Normally, when there is no data returning from the query, I would do it by going Tablix Properties and assign "No Data" to the NoRowsMessage property. This is not working for this situation, and I could not figure out how I can count the displayed row number in a matrix. Any help would be appreciated.
You can do this by adding a row add the end of the tablix and outside the Row Group.
Once the row is created type No Data in the first cell of the row.
Select the No Data row and go to Row Visibility property and set this expression:
=IIF(
Sum(IIF(Fields!Grade.Value>95,1,0))>0,True,False
)
When all rows have Grade 95 or less the No Data row will be shown but the data rows will be hidden.
UPDATE Update based on OP's feedback. Grade column is an sum expression.
In that case it is useful use the LookupSet function to get the grades by ID. They will be returned in an array data type so we require custom code to sum the ID grades.
Go to Report Menu / Report Properties..., select the Code tab and paste the following code.
Dim HiddenFlag as Integer = 0
Function CalculateHiddenFlag(ByVal items As Object()) As Integer
If items Is Nothing Then
Return HiddenFlag
End If
Dim sumItems As Decimal = New Decimal()
sumItems = 0
For Each item As Object In items
sumItems += Convert.ToDecimal(item)
Next
If (sumItems > 95 and HiddenFlag=0) Then
HiddenFlag = 1
End If
Return 0
End Function
Function GetHiddenFlag() As Integer
Return HiddenFlag
End Function
Now modify the [Sum(Grade)] cell expression an use this one:
=Sum(Fields!Grade.Value)+
Code.CalculateHiddenFlag(
LookupSet(Fields!ID.Value,Fields!ID.Value,Fields!Grade.Value,"DataSet15"))
Replace DataSetName by the actual name of yours.
Your matrix should look like this:
For the No Data row visibility property use the following expression:
=IIF(Code.GetHiddenFlag()=1,True,False)
It will return this when at least one row has Grade > 95.
And this when there is no rows which Grade is greater than 95.
Let me know if this helps.

Reporting Services - How to get sum of values using reportitems!textbox1.value

I am using custom code to get the sum of values using reportitems!textbox1.value because I know I cannot use it without custom code because of the error 'Aggregate functions can be used only on report items contained in page headers and footers'. I am using a table inside a list with the list group 'list1_Details_Group'. I am succeeding in getting the sum with the following code but it is not giving the sum per 'list1_Details_Group'.
What I want is to have the total of the values per the 'list1_Details_Group'
My code is:
Public sum_of_crew As Integer = 0
Public Function SumUp(ByVal value As Integer) As Integer
sum_of_crew = sum_of_crew + value
Return sum_of_crew
End Function
I am calling this function from a textbox inside my table detail row with the expression which accumulates the value:
=Code.SumUp(ReportItems!textbox134.Value)
I then have another textbox inside the list outside the table with the following expression which shows the sum:
=Code.sum_of_crew
This textbox which is supposed to show the accumulated sum as per the last value in the table detail row is giving the correct sum but only for the first of the group values as the second of the group values are including the value of the first of the group values. The value does not start at 0 again after the value of the first of the group values.
Please help!
I have played around and did the following which is working for me and I hope it will help somebody else.
I created a group named 'table1_Group1' inside my table by right clicking on the detail row on the detail icon on the left (not on the fields) and choosing 'Insert Group' then on the 'General' tab at the 'Group on:' I chose on the Expression dropdownlist the same field I used at my List Detail Group. I only left 'Repeat group footer' checked. The reason for the group in the table is to include the rownumber of the group in my code to reset the value to 0 each time the group row number starts at 1. I then changed my code to this:
Public sum_of_crew As Integer = 0
Public Function SumUp(ByVal value As Integer,ByVal value2 As Integer) As Integer
If value2 = 1 then
sum_of_crew = 0
End If
sum_of_crew = sum_of_crew + value
Return sum_of_crew
End Function
I am calling this function from a textbox inside my table detail row with the expression which accumulates the value which I changed to include the rownumber of the group I have created inside my table:
=Code.SumUp(ReportItems!textbox134.Value,RowNumber("table1_Group1"))
I then have another textbox inside the list outside the table with the following expression which shows the sum:
=Code.sum_of_crew
With the above changed code and expressions the total value per group is now showing at the bottom of each group by using reportitems!.....value instead of fields!.....value.
Credit to Daren with an answer on a forum who gave me direction.

How do i reference the value of a control in a rowsource query?

Im trying to write a query that will pull the value of the selected item in a combobox to use in a WHERE clause.
For example, the user selects "Jeff" out the combobox that is named cboNames. The bound value is 1 (the primary key). I'm trying to create the query:
select * from tbleEmployees where empID = cboNames.Value
obviously this doesn't work. Get what I'm trying to do?
How do i place the control value into the query??
select * from tbleEmployees where empID = [Forms]![YourForm]![cboNames]