Showing posts with label expected. Show all posts
Showing posts with label expected. Show all posts

Friday, March 30, 2012

Problems instancing Reporting Services

I set up Reporting Services as a Web Reference and when I try to instance it, I get a "type expected" error message. Let's say the web reference is named SQLRS. When I do a DIM rs as NEW SQLRS, a blue squiggly appears under SQLRS and it displays the type expected error message.

What am I missing? Anyone know or have a link to an example I could look at? Thanks for any help.Additional information:

When I bring up the Reporting Services as a web reference, I don't get a drop down list of the methods and properties that are listed in the Add a Web Reference dialogue box and from what I've seen in examples online. For instance, there should be a ListChildren method, but I don't see it when intellisense kicks in.

Example: Let's say I name the web service ReportingService. If I try to instance it by going DIM rs as NEW ReportingService, I get the blue squiggly line complaining that "Type expected". If I type ReportingService. intellisense kicks in, but what appears in the drop down box is not what I expect. There are no ListChildren, ListEvents, ListJobs, etc.

What I suspect is that I need to DIM the ReportingService with one of the selections from the intellisense dropdown box, but I have no idea which one as all the examples I've seen online show differently. Has there been changes to this with service pack 2 that I'm not aware of? Any help would be appreciated.|||Ok, I just love answering my own questions.

It turns out that all the examples I've been trying to follow are a bit off. To create an instance of the Reporting Services as a web service, first add the web service as a web reference to your project. (i.e., right click on references in the solution explorer and type in the web address of the reporting services: http://myserver/ReportServer/ReportService.asmx)

Then, to create an instance, use something like:

DIM rs as NEW ReportingService.ReportingService

Now you will have an object called rs that will have the properties and methods of the ReportingService web service such as ListChildren, ListJobs, Render, etc.

Saturday, February 25, 2012

Problem with using Round() in mdx

I am using Round function in MDX. It is not giving expected result. It always gives nearest even number as result.

I am running following mdx:

with member

[Measures].[Calculated Score25]

as 'Round(2.5, 0)'

member [Measures].[Calculated Score35]

as 'Round(3.5, 0)'

select {

[Measures].[Calculated Score25],

[Measures].[Calculated Score35]}

on columns from Cube1

This mdx gives following result

Calculated Score25 Calculated Score35
2 4

When expected result is 3, 4

I agree it's strange, and when I first looked at your results I thought this was a bug. But then I looked at some descriptions of the round function and I suspect this behaviour is intentional:

http://www.techonthenet.com/access/functions/numeric/round.php

Anyway, you can get the value you want using the Excel round function, assuming you have the Excel function library available on your server:

with member

[Measures].[Calculated Score25]

as 'excel!round(2.5,0)'

member [Measures].[Calculated Score35]

as 'excel!Round(3.5,0)'

select {

[Measures].[Calculated Score25],

[Measures].[Calculated Score35]}

on columns from [Adventure Works]

HTH,

Chris

|||

This MS Support article explains various rounding algorithms - for example, VBA Round() performs "Banker's Rounding", whereas Excel Round() does "symmetric arithmetic rounding":

How To Implement Custom Rounding Procedures

...

SUMMARY

There are a number of different rounding algorithms available in Microsoft products. Rounding algorithms range from Arithmetic Rounding in Excel's Worksheet Round() function to Banker's Rounding in the CInt(), CLng(), and Round() functions in Visual Basic for Applications. This article describes what the various Visual Basic for Applications rounding functions do and provides samples of using the functions. In addition, the article includes sample functions that implement various rounding algorithms.

But if you need asymmetric arithmetic rounding, it looks like inverted VBA Int() would work:

with

member [Measures].[Score25] as 2.5

member [Measures].[Score35] as 3.5

member [Measures].[Calculated Score25]

as '-int(-[Measures].[Score25])'

member [Measures].[Calculated Score35]

as '-int(-[Measures].[Score35])'

select {

[Measures].[Calculated Score25],

[Measures].[Calculated Score35]}

on columns from [Adventure Works]

-

Calculated Score25 Calculated Score35
3 4