Showing posts with label dataset. Show all posts
Showing posts with label dataset. Show all posts

Sunday, March 25, 2012

Calculated fields in Matrix

Hi!

I have a calculated field in a dataset, Productivity, defined by this expression:

Fields!BCM.Value/Fields!MINUTES.Value

When I use it on a table, everything works fine. But when I try to use it on a matrix, I get an error
(#ERROR) on the field.
Why does it happen? Can't I use calculated fields on matrix?

Thank you!

Dear,

Sure , u will get the error beause u are using the field in matrix but when u define the function u are not passing the matrix refrence.

eg:

=iif(inscope(Sum(Fields!OrderQty.Value, "MatrixSource")),sum(Fields!OrderQty.Value),sum(Fields!OrderQty.Value)/Sum(Fields!OrderQty.Value, "MatrixSource"))

HTH

from

sufian

Calculated Fields

I have two questions regarding calculated fields.
I have a report with two datasets.
Issue 1:
Dataset 1 queries a table that contains configuration information. This
table has one row.
I would like to create a calculated field that divides the value of a
column in this one row but another value in the one row. The problem
appears to be that SRS is expecting the query to return 1 or more rows,
and thus only likes to let me do aggregations on the output from the
dataset. Is there a way to either tell it that there will only be one
row, or a different way to extract the config info from the database
that makes more sense?
Issue 2:
I would then like to use the output of the calculated field from issue
one as part of a calculated field in the second dataset. This seems to
be a problem, as SRS complains with the following statement:
=Sum(Fields!INVOICEAMOUNT.Value, "DailySalesDS") /
Fields!DailyInvoiceProRateMultiplier.Value, "InputDataDS"
Will not compile. I get errors regarding aggregates in report
parameters and about using something from another dataset.
My guess is that I am going about this the wrong way. Any help is
appreciated.In case you missed it, I have answered your questions already in the
"Computed Fields/Multiple Datasources" thread yesterday.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hunter Hillegas" <hunter.hillegas@.gmail.com> wrote in message
news:chtc25$sd9@.odbk17.prod.google.com...
> I have two questions regarding calculated fields.
> I have a report with two datasets.
> Issue 1:
> Dataset 1 queries a table that contains configuration information. This
> table has one row.
> I would like to create a calculated field that divides the value of a
> column in this one row but another value in the one row. The problem
> appears to be that SRS is expecting the query to return 1 or more rows,
> and thus only likes to let me do aggregations on the output from the
> dataset. Is there a way to either tell it that there will only be one
> row, or a different way to extract the config info from the database
> that makes more sense?
> Issue 2:
> I would then like to use the output of the calculated field from issue
> one as part of a calculated field in the second dataset. This seems to
> be a problem, as SRS complains with the following statement:
> =Sum(Fields!INVOICEAMOUNT.Value, "DailySalesDS") /
> Fields!DailyInvoiceProRateMultiplier.Value, "InputDataDS"
> Will not compile. I get errors regarding aggregates in report
> parameters and about using something from another dataset.
> My guess is that I am going about this the wrong way. Any help is
> appreciated.
>sql

Thursday, March 22, 2012

Calculated field in dataset using Previous() function

Hi,
Iam trying to add a calculated field to my report dataset which based on
value of a field in the previous row. The calculated field is defined as
=IIf(Previous(Fields!Col1.Value)=Fields!Col1.Value,0,CDbl(Fields!Col2.Value)+CDbl(Fields!Col3.Value))
. Iam basically checking the value of Col1 in previous row with value in
current row. Iam getting the following error when tried to build the report
"An internal error occurred on the report server. See the error log for more
details.". I could not find anything in error log.
Can anyone help in resolving this problem ?
Thanks,
RKOn Dec 3, 1:35 am, "S V Ramakrishna"
<ramakrishna.seeth...@.translogicsys.com> wrote:
> Hi,
> Iam trying to add a calculated field to my report dataset which based on
> value of a field in the previous row. The calculated field is defined as
> =IIf(Previous(Fields!Col1.Value)=Fields!Col1.Value,0,CDbl(Fields!Col2.Value-)+CDbl(Fields!Col3.Value))
> . Iam basically checking the value of Col1 in previous row with value in
> current row. Iam getting the following error when tried to build the report
> "An internal error occurred on the report server. See the error log for more
> details.". I could not find anything in error log.
> Can anyone help in resolving this problem ?
> Thanks,
> RK
I found that the Previous(Fields!XYZ.Value) function only works in the
Table and Matrix expressions -- expresions that are evaluated at
render time. Although it would make sense to have them in the DataSet
as a calculated field, I've not been able to get this to work.
Oracle has LAG and LEAD functions that return the previous/next value
of a Field as part of the query results. Microsoft T-SQL does not
have an equivalent.
-- Scottsql

Calculated field in a dataset

Hi All,

I have a dataset with the following fields

Name Value

ABC 100

DEF 150

GHI 180

Now i need to have a calculated field DIFF which will calculate the difference in the value of the current row and the previous row. The report should have the following fields:

Name Value DIFF

ABC 100 NULL

DEF 150 50

GHI 180 30

Any pointers on how to achieve this requirement will help.

Thanks in advance,

Arun

You can do this with a custom function. Place the following, in the Code section of the Report. Using Report Designer this is on the Code tab of the Report Properties Dialog.

Private m_previousValue As Integer = 0

Public Function ComputeDifference(currentValue as Integer) as Integer

Dim diffValue as Integer = currentValue - m_previousValue
m_previousValue = currentValue

Return diffValue

End Function


The value for the calculated field:

=Code.ComputeDifference(Fields!Sales_Amount.Value)

|||

you can use previous function of the reproting services. these function will give the previous value.

substract the current value from the previous value.

Tuesday, March 20, 2012

Calculate the values from a underlying table

I am building a customerlist within the customer sales of a period. I have a dataset with two tables: "customer" and "customer_ledger_entry".

In the report I will present the customer number, the customer name and the sales. The problem is the sales value is not available as a field, but I have to calculate this value from the "customer_ledger_entry" table. In this table are several entries (invoices, credit notes, etc.)

How to calculate the values from a underlying table?

Here is a post that may work. You would populate the sales value into a dictionary object and then reference it based on the key you decide to use.

(from my blog at http://sqlrs.blogspot.com)

One common problem in reporting and BI solutions is how to incorporate data from both an OLAP cube and relational tables. The UDM in SQL 2005 attempts to solve this, however it really means you still need to build the information into your cubes and dimension attributes.

What if you don't want to or can't?

Reporting Services provides a Custom Code tab within the Report Properties page. You can access various VB.NET objects and system assemblies, and reference external assemblies. One of the internal assemblies is the Dictionary object.

Steps to lookup values from a reference table in SQL:

Drag a list onto the report.
Drag a textbox into the list, or a field from the relational dataset. Modify the textbox to contain =Code.setValue(Fields!KeyField.Value, Fields!ValueField.Value)

Create another list below. Drag another textbox into the list. Modify the textbox expression to hard-code the key for now. =Code.getValue("MyKey")

In the Code Properties window, try the following:

public dict as new System.Collections.Generics.Dictionary(Of System, System)

function setValue(value as object, value2 as object) as object
dict.Add(value,value2)
return value
end function

function getValue(value as object) as object
return dict(value)
end function

Afterwards, you can hide the list box (or table or whatever) that loads the variable with the setValue function. The dictionary still gets populated.

If you have properly bound a table to the first list control, you should be able to lookup results in the second table.

This can be applied in many scenarios, including adding relational reference data to MDX results, and creating a relationship between two separate datasets.

I'd be interested to know if anyone uses this. It seems to have many different applications. One could possibly involve showing two sets of information, for things like variances or budget vs. actual data. If a value doesn't exist in the dictionary, the original field could be returned. If it does exist, the adjustment could be returned.

Note that Generics is .NET 2.0 - for 2000 you may need to use a different syntax but the concept is the same. Basically you're using a dictionary object (could be a hash table or whatever) to store a value by a key. Then you're looking up that value in a table (or list or whatever) to do further calculations.

cheers,

Andrew

|||

Selectis,

I believe you may want to create 2 dataset for your report, the first dataset for the "customer" and the second dataset for "customer_ledger_entry". You can then calculate your values like SUM(Fields!Sales.value,"customer_ledger_entry", customer name like =(Fields!FirstName,"customer")

I hope this was what you were looking for.

Ham

|||

I've made a the two datasets like you said. My expression is:

=Sum(Fields!Sales__LCY_.Value, "customer_ledger_entry"), (Fields!Customer_No_.Value, "customer_ledger_entry") like = (Fields!No_.Value, "customer")

When I run the report I get the message "The Value expression for the textbox refers to a the field "Customer_No_". Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope.

|||

Selectis,

I must have misunderstood what you were trying to accomplish, I thought you when trying to display values from 2 different tables but I didn’t realize you want to reference the 2 datasets together.

If you can do the following:

You can nest data regions within other data regions. For example, if you want to create a sales record for each sales person in a database, you can create a list with text boxes and an image to display information about the employee, and then add table and chart data regions to show the employee's sales record.

I hope this helps

Ham

|||

I′ve found a way to calculate the value: I use one dataset with two tables: "customer" and "customer_ledger_entry".

The report contains a table and I've used the SUM function for the customer sales: =SUM(Fields!Sales.Value). Now my report calculates all the sales lines from the "customer_ledger_entry". That is not what I want. But the solution is to choose "Edit Group" for the detail line in your report. In the Group settings I added a sorting on the customer and I added a "Group on" expression. Now the SUM function only calculates the records for the customer listed on the line.

Wednesday, March 7, 2012

cached datasets?

Hello all,

I have a report with a table and a chart. It uses dataset1 as the data source.

All works fine.

I create a new dataset called dataset2.

The queries are exactly the same. The only differences between the 2 datasets is the database server and the fact that one of the columns is a smallint (in dataset2) and an int(in Dataset1)

I change the datasetName property of both the table and the chart to use dataset2.

When I run the report I get a conversion error stating that there was an overflow of int2 while using dataset1. I have verified the report is not using dataset1 anywhere. If I delete dataset1 and run the report the error goes away. If I add it back, I get the error again. Why is the report looking at dataset1 if it is not referenced at all in the report? Does SQL RS cache the datasets and verify each when it compiles?

regards,

Bill

Sometimes I have noticed that Business Intelligence Studio is not so intelligent. In the XML, it may not be changing your dataset from dataset1 to dataset2.

When this happens to me, I switch to the layout tab. Next, click view code. Search this XML document for any occurance of dataset. You should find something like this:

<DataSetName>dataset1</DataSetName>

If you find any in the XML that say dataset1, then change them to dataset2. Save your project and rebuild and see whether that takes care of it for you.

|||I see instances of the dataset1 in the XML. I have many reports that I need to have multiple datasets created, but not used. I have 3 locations(servers) that will use the same reports. I need a different dataset created for each. I would really love not to have to recreate the dataset for each location whenever I make a change to the report.

|||

Woyler wrote:

I see instances of the dataset1 in the XML. I have many reports that I need to have multiple datasets created, but not used. I have 3 locations(servers) that will use the same reports. I need a different dataset created for each. I would really love not to have to recreate the dataset for each location whenever I make a change to the report.

Dataset1 will still be stored on the layout of the report if you change dataset1 to dataset2 in the XML.

You will not have to recreate the dataset. You are simply manually telling the report which dataset to use, since Business Intelligence Studio was not intelligent enough to change the XML for you.

|||Thanks for your replies. I searched the XML for the <datasetname> tag. All instances of the tag are correct. There is no mention of dataset1. Any other places to look?|||

No, rebuild and deploy the report and see if you get the same error.

|||If I rebuild I get the same error. Like I said if I delete the dataset1 , it works fine. If I add the dataset1 back in , I get the error. It seems that the simple existence of the dataset causes the report to validate it.

|||Have you tried commenting the query in dataset1 out?

|||

That works. Thanks for the help.

I hope someone(hello Microsoft) will chime in here and provide a logical explanation for this.

Best regards,

Bill

Saturday, February 25, 2012

C++ .net data binding

I have a datagrid control bound to a dataview of a table in a dataset.
I am using a tablestyle to control which of the table columns are
displayed in the datagrid. When any cell in a row is selected I want to
select and highlight the entire row.
By catching the mousedown event and using HitTest I can work out what
row was clicked on the control and set the selected row but I can
highlight the row.
Can anyone tell me where I am going wrong ?"Jez" <jezario@.hotmail.co.uk> wrote in message
news:1129131568.948426.123380@.g14g2000cwa.googlegroups.com...
>I have a datagrid control bound to a dataview of a table in a dataset.
> I am using a tablestyle to control which of the table columns are
> displayed in the datagrid. When any cell in a row is selected I want to
> select and highlight the entire row.
> By catching the mousedown event and using HitTest I can work out what
> row was clicked on the control and set the selected row but I can
> highlight the row.

> Can anyone tell me where I am going wrong ?
Posting in the wrong newsgroup. :-)

Sunday, February 12, 2012

Businees Intelligence: Is it possible to return more than one tables in dataset


Is it possible to return a dataset contain more than one tables inside it....... andreceive in reporting services?

You can perform a join in your query if you wish, but each dataset can only access a single record set.

You can however setup multiple datasets and use these concurrently within your report.

Taz