Showing posts with label dynamically. Show all posts
Showing posts with label dynamically. Show all posts

Monday, March 12, 2012

Expressions not evaluating values?

Hi,

I use an expression in a column text box to dynamically compute the column title.

The problem must have something linked to the way expressions generally works. I do not understand it clearly.

In this example, I use a SWITCH function to test the numerical value of a 1 row 1 column dataset.

The problem is that I can test the number only if it is lower or equal to the number in the dataset. if I test a number greater than the number in the dataset, I get an error.

How can I get this test to work if the value tested is greater than the value in the dataset?

Thanks

Philippe

Bellow is the code.

-

=switch(

First(Fields!HeaderCount.Value, "HeadersCount") < 2

, nothing

, First(Fields!HeaderCount.Value, "HeadersCount") = 2

, Right(Parameters!Headers.Value, Len(Parameters!Headers.Value) - Parameters!Headers.Value.IndexOf(",2,")-3)

, First(Fields!HeaderCount.Value, "HeadersCount") > 2

, Parameters!Headers.Value.Substring(

Parameters!Headers.Value.IndexOf(",2,")+3

, Parameters!Headers.Value.IndexOf(",3,")-Parameters!Headers.Value.IndexOf(",2,")-3

)

)

Philippe wrote:

is that I can test the number only if it is lower or equal to the number in the dataset. if I test a number greater than the number in the dataset, I get an error.

Note, If the dataset contains 2, the expression will return an error because I try to test >2 in the last case.
if the dataset contains 3 or greater, it works fine.

it is clearly the test which fails because if I replace the action by a fixed string it still return an error.

|||

You are using the switch() function. Since it is a function, all arguments are evaluated before the switch functionality is executed.

I recommend to write a custom code function that uses the VB switch statement and call the custom code function from the expression.

-- Robert

|||

Hi,

I have made some research on the Custom Code however I could not find documentation nor examples that show how to use parameters or dataset values within the custom code. If I create a function like this How can I access the report items?

Public Function Headers(ByVal Column as Integer) As String
Return CStr(Microsoft.VisualBasic.Switch( _
First(Fields!HeaderCount.Value, "HeadersCount") < Column _
, nothing _
, First(Fields!HeaderCount.Value, "HeadersCount") = Column _
, Right(Parameters!Headers.Value, Len(Parameters!Headers.Value) - Parameters!Headers.Value.IndexOf(",Column,")-3) _
, First(Fields!HeaderCount.Value, "HeadersCount") > Column _
, Parameters!Headers.Value.Substring( _
Parameters!Headers.Value.IndexOf(",Column,")+3 _
, Parameters!Headers.Value.IndexOf(",Column + 1,")-Parameters!Headers.Value.IndexOf(",Column,")-3 _
) _
) _
)
End Function

I did find a much simpler solution though.

The string I use contains a variable number of names separated by indexes, i.e.

,1,Charles,2,Tom,3,Laura,4,Rick

I have a report with a fixed number of columns, i.e 50 columns and I populate the columns title by pulling from the string, i.e. Column 3 title will be Laura.

I have converted the string so each name will have trailing spaces. Since now each item has the same lenght, I do not need anymore the switch, I can do simply this in each column with just another index number. Then I use an expression to control the visibility of the column.

Title

=Parameters!Headers.Value.Substring(Parameters!Headers.Value.IndexOf(",3,")+3, 85)

Visibility

=iif(First(Fields!HeaderCount.Value, "HeadersCount")<3,True,False)

If I spend the time to build this instead of using the Matrix report, it is because the Matrix report has 2 majors issues for me.

1) You cannot have column titles for your categories

2) You cannot have the categories values repeated

Because of the strict format requirement I have, I am obliged to use the PIVOT SQL operator and the dynamic column population. My users want a pivoted flat file they can put in Excel and build a pivot table with it. You cannot do that with a matrix report, too bad. That would be so much easy.

Philippe

Wednesday, March 7, 2012

Expression based min max settings for Y-axis

Hi,
I have a chart which has scalable Y-axis. I want to set the scale of the
Y-axis dynamically when the report loads based on the maximum and minimum
values the Y-axis variables can take. How do I do that?
Thanking you,
Jd.Check
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=fb9be106-99d0-49f2-b36d-c84e333eb275&sloc=en-us
for details.
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:ADECAA95-40FC-415A-BECC-0084FB342690@.microsoft.com...
> Hi,
> I have a chart which has scalable Y-axis. I want to set the scale of the
> Y-axis dynamically when the report loads based on the maximum and minimum
> values the Y-axis variables can take. How do I do that?
> Thanking you,
> Jd.

Friday, February 17, 2012

Exporting text files

Hi,
Is there any way to export .rpt files as text files. I am using crystal reports 9.0 and .Net framework..
I want to export them dynamically in the code.
I could able to export to pdf,doc and html..But not to text.
Thanks,
RameshYou have to include the right dlls in order for the export to work. I use Crystal Reports Version 8.5 and there's a list of the required files in a file called runtime.hlp. (The file may be called something different with other versions of Crystal)

There are 2 types of dlls to include when you want to export: Export Destinations (Application, Disk, MAPI, Lotus Domino, etc... ) and Export Formats (HTML, pdf, doc, text, etc... ). In order to be able to export to text, I had to include U2FTEXT.DLL (from the Export Formats, this dll exports to text format) and U2DDISK.DLL (from the Export Destinations, this dll exports to disk instead of application). I couldn't get it to work if I just included the file to output to application.

Just remember that this is for CR 8.5 and VB 6, so you may or may not be able to use it, but I hope it helps anyway!|||I want to export multiple crystal reports in one file.. i.e. only one text file / pdf file or any other format... in short i want to merge the reports.
can anyone help me in that.. ?|||Hi! i too face the same prob but the differance if i want to export multipal subreport with main report in one pdf file.
Any one who can help me out plz plz do reply its urgent.
Thanks in advance|||aj_patil: When you export the main report, the subreports will be exported with it. No need to do anything else.

dhmshah: Perhaps you can set each of your reports as subreports in one main report. Other than that, I'm not sure if multiple reports can be exported into 1 file.

Also, if you have a new question, you should post it in a new thread instead of onto an old thread. That way, other people who have the same question as you can find the answer easier.|||aj_patil: When you export the main report, the subreports will be exported with it. No need to do anything else.

dhmshah: Perhaps you can set each of your reports as subreports in one main report. Other than that, I'm not sure if multiple reports can be exported into 1 file.

Also, if you have a new question, you should post it in a new thread instead of onto an old thread. That way, other people who have the same question as you can find the answer easier.

Thanks for the advice but i hv tried, any way if u get any link hear after do write to me.|||I want to export multiple crystal reports in one file.. i.e. only one text file / pdf file or any other format... in short i want to merge the reports.
can anyone help me in that.. ?

thanks for the advice. but if u get any infomation related do write- aj