Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Tuesday, March 20, 2012

conditional widths

I have a report with columns which the user may optionally turn on. when
these columns are not displayed (hidden=true), the report fits nicely in
legal sized paper, and when the columns are displayed, it is typically
because the report will be exported to Excel.
here's my quandary: if I assign those optional columns a particular width,
the report exceeds the paper size (even though the columns are hidden),
causing extra pages to print (blank). the solution is to make those columns
0 width (or as close as Reporting Services will allow)... however, when
exporting to Excel, the columns have to be manually expanded. grr...
the answer would be conditional width sizes i.e. if a report parameter
specifies display of the columns then use one width, otherwise make the width
0... but the width property doesn't seem to accept an expression.
has anyone out there faced this same problem? any ideas of how I can
address it?
thx - ekkisI am having a similar problem, I want conditional widths so that I can use
the same report for different years. I have information broken down by weeks
and want the parameter to be the year, based on that parameter I need the
month name above the week names to change in size. Haven't figures it out
yet...

conditional where statement

I have a stored procedure that performs a search function with params:

@.username nvarchar(50)
@.country nvarchar(50)
and like 10 more.

A user may provide values for these params optionally.
So when the @.username var is left blank, there should be no filtering on the username field (every field should be selected regardless of the username)
Currently my statement is:

select username,country from myUsers where
username=@.username andcountry=@.country

With this statement when a user provides no value for username the username field selects on ''m which returns ofcourse nothing...

What can I do to solve this?

Thanks!

SELECTFROM YourTableWHERE (@.usernameISNULL OR UserName = @.username )AND (@.countryISNULL OR Country = @.country )
|||

Thanks, but in this case the username field would not be ignored.
If someone has filled in a username, say "peter", but the webvisitor would not want to search on any username, the statement would be:

SELECT
FROM YourTable
WHERE (@.usernameISNULL OR UserName = '' )

In this case the user with name "peter" would not be found. If a webvisitor does NOT provide a username, I want to return all rows regardless of the value in the username field...

Im just hoping I've explained myself clearly now :)

Thanks!

|||

use WHERE (UserName = COALESCE(@.UserName, UserName)) AND (Country = COALESCE(@.Country, Country)) AND etc.

COALESCE (or ISNULL if you prefer) will return the first value in the parameter list that is not null, so if you pass a NULL value for, say, @.UserName, that part of the WHERE clause will resolve to "WHERE UserName = UserName", which of course, is always true.

|||

Peter Smith:

If someone has filled in a username, say "peter", but the webvisitor would not want to search on any username

Can you explain what you mean by that? If there is a value in @.username, it will be searched against, else ignored. If there is a value provided and it does not exist in the table, obviously nothing will be returned. Incase the query doesnt work as expected, please provide some sample data, and sample scenarios and their expected outputs.

|||

Dinakar Nethi provided an excellent query for your issue. The key to implement is:

You need to set your input parameter to default NULL first.

@.UserName NVarchar(50) = NULL,

@.Country NVarchar(50) = NULL

|||

mmm, I see (now). I tested your query and it works :)
Thanks!

Conditional visibility

I have a table with US dollar amounts. The user wants to see these
amounts by default, but would like the ability to view their original
currency amounts.
If the original currency amount = the US dollar amount, I don't want
the user to be able to make that row viewable. How can I prevent them
from even seeing the plus sign that would indicate additional data?
Thanks,
MikeWhile , as you know, you can make a row or column conditionally visible with
an expression on the visibility property. But the Toggle column can not be
turned off or on, just shown or hiddent...
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Bassist695" <Michael.EJ.Reynolds@.gmail.com> wrote in message
news:1116612976.587559.300370@.f14g2000cwb.googlegroups.com...
>I have a table with US dollar amounts. The user wants to see these
> amounts by default, but would like the ability to view their original
> currency amounts.
> If the original currency amount = the US dollar amount, I don't want
> the user to be able to make that row viewable. How can I prevent them
> from even seeing the plus sign that would indicate additional data?
> Thanks,
> Mike
>

Thursday, March 8, 2012

Conditional Parameters

Hi all
I cant get my head round conditional parameters. I have a report with two
parameters and I would like the user to be able to select either one or both
of the parameters.
IE.
Param 1 Firstname
Param 2 Lastname
The user should be able to enter into the first parameter, or the second
parameter or both. How do I acheive this and construct the SQL accordingly.
Thanks
Dave.David,
I used similar code in one of my reports:
where FirstName like (case when IsNull(@.FName, '') = '' then '%' else '%' +
@.FName end)
and LastName like (case when IsNull(@.LName, '') = '' then '%' else '%' +
@.LName end)
HTH,
Andrei.
"David Hines" <DavidHines@.discussions.microsoft.com> wrote in message
news:249315AC-DE87-4AF6-8013-025A9CA4EA81@.microsoft.com...
> Hi all
> I cant get my head round conditional parameters. I have a report with two
> parameters and I would like the user to be able to select either one or
both
> of the parameters.
> IE.
> Param 1 Firstname
> Param 2 Lastname
> The user should be able to enter into the first parameter, or the second
> parameter or both. How do I acheive this and construct the SQL
accordingly.
> Thanks
> Dave.|||Hi Andrei
You pointed me in just the right direction Thankyou.
Finished SQL was
WHERE (FirstName LIKE '%' + (CASE WHEN IsNull(@.Fname, '') = '' THEN '%'
ELSE @.Fname END) + '%') AND (LastName LIKE '%' + (CASE WHEN IsNull(@.LName,
'') = '' THEN '%' ELSE + @.Lname END) + '%') AND (LEN(@.Lname) +
LEN(@.OwnerCode) > 0)
Again Many Thanks for your speedy response.
Dave.
"andrei" wrote:
> David,
> I used similar code in one of my reports:
> where FirstName like (case when IsNull(@.FName, '') = '' then '%' else '%' +
> @.FName end)
> and LastName like (case when IsNull(@.LName, '') = '' then '%' else '%' +
> @.LName end)
> HTH,
> Andrei.
>
> "David Hines" <DavidHines@.discussions.microsoft.com> wrote in message
> news:249315AC-DE87-4AF6-8013-025A9CA4EA81@.microsoft.com...
> > Hi all
> > I cant get my head round conditional parameters. I have a report with two
> > parameters and I would like the user to be able to select either one or
> both
> > of the parameters.
> >
> > IE.
> >
> > Param 1 Firstname
> > Param 2 Lastname
> >
> > The user should be able to enter into the first parameter, or the second
> > parameter or both. How do I acheive this and construct the SQL
> accordingly.
> >
> > Thanks
> >
> > Dave.
>
>|||Another solution - I just don't like using LIKE...
--
WHERE (FirstName = @.Fname OR @.Fname IS NULL)
AND (LastName = @.Lname OR @.Lname IS NULL)
AND ...
--
This works very well when you have "<ALL>" as an option for a parameter.
Fred
"David Hines" wrote:
> Hi Andrei
> You pointed me in just the right direction Thankyou.
> Finished SQL was
> WHERE (FirstName LIKE '%' + (CASE WHEN IsNull(@.Fname, '') = '' THEN '%'
> ELSE @.Fname END) + '%') AND (LastName LIKE '%' + (CASE WHEN IsNull(@.LName,
> '') = '' THEN '%' ELSE + @.Lname END) + '%') AND (LEN(@.Lname) +
> LEN(@.OwnerCode) > 0)
> Again Many Thanks for your speedy response.
> Dave.
>
> "andrei" wrote:
> > David,
> >
> > I used similar code in one of my reports:
> >
> > where FirstName like (case when IsNull(@.FName, '') = '' then '%' else '%' +
> > @.FName end)
> > and LastName like (case when IsNull(@.LName, '') = '' then '%' else '%' +
> > @.LName end)
> >
> > HTH,
> > Andrei.
> >
> >
> > "David Hines" <DavidHines@.discussions.microsoft.com> wrote in message
> > news:249315AC-DE87-4AF6-8013-025A9CA4EA81@.microsoft.com...
> > > Hi all
> > > I cant get my head round conditional parameters. I have a report with two
> > > parameters and I would like the user to be able to select either one or
> > both
> > > of the parameters.
> > >
> > > IE.
> > >
> > > Param 1 Firstname
> > > Param 2 Lastname
> > >
> > > The user should be able to enter into the first parameter, or the second
> > > parameter or both. How do I acheive this and construct the SQL
> > accordingly.
> > >
> > > Thanks
> > >
> > > Dave.
> >
> >
> >

Conditional Parameters

Does anyone know if there is a way to have conditional parameters? Ex: User
asked would you like to run report by representative or area? Then when the
user chose representative a mulit select prompt would appear with a list of
representatives to choose from or if they chose area then a multi selection
of areas to choose from would appear.Hi Kim,
Yes it can be done. From your post, you need to create 3 dataset.
1. Which gives you Rep.. or Area
2. Which gives you the list of rep for selection (multi selection)
3. Once you select it displayes the result.
On 2 & 3 data option give an if condition accordingly
e.g
If @.rep = 1
select * from rep
else
select * from Area
Any doubts, Let me know.
Amarnath
"KimB" wrote:
> Does anyone know if there is a way to have conditional parameters? Ex: User
> asked would you like to run report by representative or area? Then when the
> user chose representative a mulit select prompt would appear with a list of
> representatives to choose from or if they chose area then a multi selection
> of areas to choose from would appear.|||Thank you! I will try that.
"Amarnath" wrote:
> Hi Kim,
> Yes it can be done. From your post, you need to create 3 dataset.
> 1. Which gives you Rep.. or Area
> 2. Which gives you the list of rep for selection (multi selection)
> 3. Once you select it displayes the result.
> On 2 & 3 data option give an if condition accordingly
> e.g
> If @.rep = 1
> select * from rep
> else
> select * from Area
> Any doubts, Let me know.
> Amarnath
>
> "KimB" wrote:
> > Does anyone know if there is a way to have conditional parameters? Ex: User
> > asked would you like to run report by representative or area? Then when the
> > user chose representative a mulit select prompt would appear with a list of
> > representatives to choose from or if they chose area then a multi selection
> > of areas to choose from would appear.

Conditional Parameter in Where Clause

I'm trying to figure out a way to filter a dataset using a parameter only when the user enters a value for the parameter and to not apply the filter if the parameter is left blank (or null) by the user. I would like to do this within the WHERE clause of the SELECT statement to minimize the size of the dataset whenever possible. Is there such a thing as a default parameter value that equates to "any value"?

Nothing I have tried works (but I'm new to SQL, Report Server and the Visual Basic Development Environment).

Thanks in advance,

Chris

Rather than leaving the parameter unselected, you need to add an option with a value of NULL and text that matches your scenario e.g. blank, "All", "N/A", "Unspecified" etc. To do this you'll need to modify the query for the paramter dataset to:

SELECT id = NULL, name = 'All'
UNION ALL
SELECT id, name
FROM param_table

Then update your main query with the following WHERE clause

WHERE id = ISNULL(@.param, id)

so when the null option is selected the WHERE clause equates to id=id which is always true and hence all rows are returned.

Hope this helps.

|||

Thanks Adam,

I was not familiar with ISNULL. I got it to work sort of like I wanted it to by checking the "Allow Null Value" checkbox and making the default value NULL in the Report Parameters dialog box and then putting this in the WHERE clause:

WHERE LITEM.SIZE = ISNULL(@.Input_Size, LITEM.SIZE)

However, I could not figure out where to put the following statement (everything I tried resulted in an error - but I'm probably missing something obvious):

SELECT id = NULL, name = 'All'
UNION ALL
SELECT id, name
FROM param_table

...and therefore, the user must uncheck the NULL checkbox in order to enter a filter value and it's not real obvious that when NULL is checked, that the filter is not applied.

Thanks again for pointing me in the right direction!

Chris

|||

By your response it seems like your parameter is a textbox the user types into, is that correct?

My prerred way is to present the user a list of options i.e. a dropdown. In that case you don't get a null checkbox. The options in the dropdown can either be typed in on the paramter screen or can come from a dataset. The SELECT statement I provided is meant as an example of query used to populate such a dataset i.e. it includes a NULL option.

If you wish to use a textbox then you could alter your SQL query and rather than using ISNULL you could use an OR in your WHERE clause as follows

WHERE LITEM.SIZE = @.Input_Size
OR @.Input_Size = '' -- empty string

If LITEM.SIZE and @.Input_Size are integers then it gets a little more complicated. You'll need to experiment.

|||

Adam,

Thanks! It's now working just the way I wanted it to!

Chris Heitman

Conditional page breaks in SSRS

Hi,

I am having trouble setting conditional page breaks to my reports.

i.e... I am having a report where I need to allow user the option to set page break between a group or not.

Based upon the option selected by the user, I need to add page break to the report. I tried with all possibilities inside Sort and Group dialog box, but could not figure out how to toggle the option at runtime.

Does anyone know how to implement page breaks on runtime? Help me plzzzz!! I really need this to be done…Thanx in advance for any help..

- Rayz

OK, I think I have succeeded in doing this...

create a boolean parameter, something like PageBreak --
I would give it a default value, but it doesn't appear to be necessary if you don't want it.
create a group with "page break at end", as you normally would. Don't put anything in its header and footer lines.
here's the trick: make this group's grouip expression an IIF() containing your "real" group expression,
something like the following example:|||

I tried it out ..but no luck for me

Wherever i apply page break..it seems it wont take the condition that i've specified..and pagebreaks appears permanently..even if i dont put pagebreak no..the page break comes..

Thanks for your suggestion

-Rayz

|||

Well, let's see...

>>it seems it wont take the condition that i've specified..and pagebreaks appears permanently

What is the condition you've specified?

Also, to make sure I can repro, is this an RDL or RDLC?

>L<

|||Perhaps you should extend the syntax that Lisa has shown with the IIF() function. If you set the group expression as previously mentioned and add a field reference that is global to the report instead of the empty field ( "" ) then perhaps this evaluate correctly.

=IIF(Parameters!PageBreak.Value, Fields!MyField.Value, Fields!MyMostGlobalField.Value)

This way you will get a field reference to evaluate the grouping to. You may additionally want to hide this group with a "Visibility" expression on the group, though you may still get a page break before your report footer if one exists.

Hope this helps.

-Paul R.
|||

Hi Paul,

It actually does work fine with the "" -- and in the past I've done this with other "global/invariant" expressions -- such as True or 1. Is there some reason why this is a bad idea?

BTW another way I do this, without an IIF(), is to group on a variable and increment the variable in code when I want to force a page break -- I haven't tried that in RS and it can be a little more difficult to manage in general. So I didn't try it in response to this query. I will try it if you think it's a better idea.


Regrads,

>L<

|||

Thanx a bunch Lisa....

ur initial suggestion worked !!

|||

Thanks for confirming!

>L<

|||

Hi,

I have five tables in a report which has to be repeated on every sheet of excel based on a variable

Can i also use the same condition?

Kindly help me out.

Thanks in advance

Nalini

|||

"Every sheet of Excel" is basically "every explicitly-requested page of the report". By that I mean you get a sheet for each page break you explicitly asked for with a page break condition, rather than the report just deciding that it has to page break based on some constraints of the host format (for example, physical page size).

So, "Excel" shouldn't be handled specifically when trying to repeat tables -- it should work the way you want, if you get the explicit page break requests correct.

I will assume you understand this (I almost wrote "that we're on the same page" <g>) and ignore the "Excel" part of the question...

So, you want to have five tables that you want to see on each page. Can you tell me some more about your layout, what each of the tables represent from the point of view of datasets? Are they related to each other or completely distinct, data-wise? Is there additional data in the report? are the tables positioned adjacent to each other vertically, or horizontally, or what?

>L<

Conditional page breaks in SSRS

Hi,

I am having trouble setting conditional page breaks to my reports.

i.e... I am having a report where I need to allow user the option to set page break between a group or not.

Based upon the option selected by the user, I need to add page break to the report. I tried with all possibilities inside Sort and Group dialog box, but could not figure out how to toggle the option at runtime.

Does anyone know how to implement page breaks on runtime? Help me plzzzz!! I really need this to be done…Thanx in advance for any help..

- Rayz

OK, I think I have succeeded in doing this...

create a boolean parameter, something like PageBreak --
I would give it a default value, but it doesn't appear to be necessary if you don't want it.
create a group with "page break at end", as you normally would. Don't put anything in its header and footer lines.
here's the trick: make this group's grouip expression an IIF() containing your "real" group expression,
something like the following example:|||

I tried it out ..but no luck for me

Wherever i apply page break..it seems it wont take the condition that i've specified..and pagebreaks appears permanently..even if i dont put pagebreak no..the page break comes..

Thanks for your suggestion

-Rayz

|||

Well, let's see...

>>it seems it wont take the condition that i've specified..and pagebreaks appears permanently

What is the condition you've specified?

Also, to make sure I can repro, is this an RDL or RDLC?

>L<

|||Perhaps you should extend the syntax that Lisa has shown with the IIF() function. If you set the group expression as previously mentioned and add a field reference that is global to the report instead of the empty field ( "" ) then perhaps this evaluate correctly.

=IIF(Parameters!PageBreak.Value, Fields!MyField.Value, Fields!MyMostGlobalField.Value)

This way you will get a field reference to evaluate the grouping to. You may additionally want to hide this group with a "Visibility" expression on the group, though you may still get a page break before your report footer if one exists.

Hope this helps.

-Paul R.
|||

Hi Paul,

It actually does work fine with the "" -- and in the past I've done this with other "global/invariant" expressions -- such as True or 1. Is there some reason why this is a bad idea?

BTW another way I do this, without an IIF(), is to group on a variable and increment the variable in code when I want to force a page break -- I haven't tried that in RS and it can be a little more difficult to manage in general. So I didn't try it in response to this query. I will try it if you think it's a better idea.


Regrads,

>L<

|||

Thanx a bunch Lisa....

ur initial suggestion worked !!

|||

Thanks for confirming!

>L<

|||

Hi,

I have five tables in a report which has to be repeated on every sheet of excel based on a variable

Can i also use the same condition?

Kindly help me out.

Thanks in advance

Nalini

|||

"Every sheet of Excel" is basically "every explicitly-requested page of the report". By that I mean you get a sheet for each page break you explicitly asked for with a page break condition, rather than the report just deciding that it has to page break based on some constraints of the host format (for example, physical page size).

So, "Excel" shouldn't be handled specifically when trying to repeat tables -- it should work the way you want, if you get the explicit page break requests correct.

I will assume you understand this (I almost wrote "that we're on the same page" <g>) and ignore the "Excel" part of the question...

So, you want to have five tables that you want to see on each page. Can you tell me some more about your layout, what each of the tables represent from the point of view of datasets? Are they related to each other or completely distinct, data-wise? Is there additional data in the report? are the tables positioned adjacent to each other vertically, or horizontally, or what?

>L<

|||

Lisa, I tried your approach and found two problems that I still can't figure out.

1) I had to do the Page break before the sections rather than after section in order for it to work.

2) I need to be able to choose the group level to page break on OR choose that no page break occurs at all. In this pursuit, I can't find a solution. Even if the Parameter!PageBreak criteria is not met, the top level group always page breaks. I need the ability to eliminate the page break as one of my options.

Any ideas?

|||

Well, it definitely does work and should not require page break before -- in fact using page break before might be why you're saying "top level always breaks".

I am not on a machine where I have any of these examples, and, clearly, we need to take this from the top.

Can I have a clear(er) statement of exactly what you've done so far in this report and also a separate statement of what the requirements are? This would optimally include some simplified SELECT or other way that I can repro exactly what your group breaks look like, there may be some collision that we have to account for that wasn't in the original suggestion (or maybe the collision *can't* be accounted for in your situation -- right now I honestly have no idea).

I'm leaving for the day now, so no rush on your response <s>

>L<

|||

I just created a stripped down sample report, and the issue with using page break after went away, but the other issue remains. I have a parameter named PageBreak with three option values: NONE, GROUP1, and GROUP2. When i choose NONE, it should always evaluate the Group1pre and Group2pre as ="" and therefore never cause a page break during the report. Unfortunately, it still causes the GROUP1 page breaks even if I choose NONE.

I created four group levels sequenced as follows (as seen in the Groups tab of Table Properties) and a detail row with the Detail values:

table1_Group1pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP1",Fields!Group1.Value,"")

table1_Group1, no page breaks, group expression =Fields!Group1.Value

table1_Group2pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP2",Fields!Group2.Value,"")

table1_Group2, no page breaks, group expression =Fields!Group2.Value

Here is the data set I created for testing.

select 'ABC' as Group1, '123' as Group2, 'slfje' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'redfg' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'wqsde' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'rdrgd' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'f5e4s6' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'rhfth' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'effgfg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'kuhjg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'efjklrg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'euurio' as Data
union all
select 'DEF' as Group1, '654' as Group2, 'wesdf' as Data
union all
select 'GHI' as Group1, '789' as Group2, 'yghfg' as Data
union all
select 'GHI' as Group1, '789' as Group2, '56215hh' as Data
union all
select 'GHI' as Group1, '456' as Group2, 'hbvfg' as Data
union all
select 'GHI' as Group1, '456' as Group2, 't456e4w' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'ouuyf' as Data
union all
select 'GHI' as Group1, '123' as Group2, '5f4g8r9' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'zzzzzzzz' as Data

|||

Thank you for taking such care to provide a reproducible sample. I will check this out and write back, whether I can do this or not, and I have no idea at the moment <s>. I do know that it's a chancey thing, and it's often tricky to get the conditional expressions right, so I usually take a while to get it to work.

Anyway, I'll give this a shot and report back...

>L<

|||

OK -- you can do this, it will work <s>. What you're missing (I think) is that you have to put the conditionals on the outer rim of the "real" groups. IOW, your group order is this:

Group1pre

Group1

Group2pre

Group2

... and it is quite possible that it would have worked something like this:

Group1pre

Group2pre

Group1

Group2

... although I didn't try it that way.

What I did try successfully, and what appears to follow the "rules of engagement" as I understand them (my understanding being without inside knowledge, just observation, and is admittedly imperfect!), is this:

GroupsPre

Group1

Group2

... using the following expression as my conditional break on GroupsPre:

Code Snippet


=IIF(Parameters!PageBreak.Value="NONE","",

IIF(Parameters!PageBreak.Value="GROUP1",
Fields!Group1.Value,

Fields!Group2.Value)
)

I want to say one other thing, based on your sample data -- which may be compounded in something you're doing in your "real" data set:

I am not sure what effect you are after on the inner group break, but you may have to dynamically sort your data to get the effect you are after when the break is on "GROUP2" (your inner group as expressed in the report). It is certainly possible to do this, of course, and I'm not even sure that is an issue for you.

[LSN Editing next morning: instead of dynamic orderng you can probably concatenate the value in the last part of the expression as csi_hugh shows in the next post]

Regards,

>L<

Conditional page breaks in SSRS

Hi,

I am having trouble setting conditional page breaks to my reports.

i.e... I am having a report where I need to allow user the option to set page break between a group or not.

Based upon the option selected by the user, I need to add page break to the report. I tried with all possibilities inside Sort and Group dialog box, but could not figure out how to toggle the option at runtime.

Does anyone know how to implement page breaks on runtime? Help me plzzzz!! I really need this to be done…Thanx in advance for any help..

- Rayz

OK, I think I have succeeded in doing this...

create a boolean parameter, something like PageBreak --
I would give it a default value, but it doesn't appear to be necessary if you don't want it.
create a group with "page break at end", as you normally would. Don't put anything in its header and footer lines.
here's the trick: make this group's grouip expression an IIF() containing your "real" group expression,
something like the following example:|||

I tried it out ..but no luck for me

Wherever i apply page break..it seems it wont take the condition that i've specified..and pagebreaks appears permanently..even if i dont put pagebreak no..the page break comes..

Thanks for your suggestion

-Rayz

|||

Well, let's see...

>>it seems it wont take the condition that i've specified..and pagebreaks appears permanently

What is the condition you've specified?

Also, to make sure I can repro, is this an RDL or RDLC?

>L<

|||Perhaps you should extend the syntax that Lisa has shown with the IIF() function. If you set the group expression as previously mentioned and add a field reference that is global to the report instead of the empty field ( "" ) then perhaps this evaluate correctly.

=IIF(Parameters!PageBreak.Value, Fields!MyField.Value, Fields!MyMostGlobalField.Value)

This way you will get a field reference to evaluate the grouping to. You may additionally want to hide this group with a "Visibility" expression on the group, though you may still get a page break before your report footer if one exists.

Hope this helps.

-Paul R.
|||

Hi Paul,

It actually does work fine with the "" -- and in the past I've done this with other "global/invariant" expressions -- such as True or 1. Is there some reason why this is a bad idea?

BTW another way I do this, without an IIF(), is to group on a variable and increment the variable in code when I want to force a page break -- I haven't tried that in RS and it can be a little more difficult to manage in general. So I didn't try it in response to this query. I will try it if you think it's a better idea.


Regrads,

>L<

|||

Thanx a bunch Lisa....

ur initial suggestion worked !!

|||

Thanks for confirming!

>L<

|||

Hi,

I have five tables in a report which has to be repeated on every sheet of excel based on a variable

Can i also use the same condition?

Kindly help me out.

Thanks in advance

Nalini

|||

"Every sheet of Excel" is basically "every explicitly-requested page of the report". By that I mean you get a sheet for each page break you explicitly asked for with a page break condition, rather than the report just deciding that it has to page break based on some constraints of the host format (for example, physical page size).

So, "Excel" shouldn't be handled specifically when trying to repeat tables -- it should work the way you want, if you get the explicit page break requests correct.

I will assume you understand this (I almost wrote "that we're on the same page" <g>) and ignore the "Excel" part of the question...

So, you want to have five tables that you want to see on each page. Can you tell me some more about your layout, what each of the tables represent from the point of view of datasets? Are they related to each other or completely distinct, data-wise? Is there additional data in the report? are the tables positioned adjacent to each other vertically, or horizontally, or what?

>L<

|||

Lisa, I tried your approach and found two problems that I still can't figure out.

1) I had to do the Page break before the sections rather than after section in order for it to work.

2) I need to be able to choose the group level to page break on OR choose that no page break occurs at all. In this pursuit, I can't find a solution. Even if the Parameter!PageBreak criteria is not met, the top level group always page breaks. I need the ability to eliminate the page break as one of my options.

Any ideas?

|||

Well, it definitely does work and should not require page break before -- in fact using page break before might be why you're saying "top level always breaks".

I am not on a machine where I have any of these examples, and, clearly, we need to take this from the top.

Can I have a clear(er) statement of exactly what you've done so far in this report and also a separate statement of what the requirements are? This would optimally include some simplified SELECT or other way that I can repro exactly what your group breaks look like, there may be some collision that we have to account for that wasn't in the original suggestion (or maybe the collision *can't* be accounted for in your situation -- right now I honestly have no idea).

I'm leaving for the day now, so no rush on your response <s>

>L<

|||

I just created a stripped down sample report, and the issue with using page break after went away, but the other issue remains. I have a parameter named PageBreak with three option values: NONE, GROUP1, and GROUP2. When i choose NONE, it should always evaluate the Group1pre and Group2pre as ="" and therefore never cause a page break during the report. Unfortunately, it still causes the GROUP1 page breaks even if I choose NONE.

I created four group levels sequenced as follows (as seen in the Groups tab of Table Properties) and a detail row with the Detail values:

table1_Group1pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP1",Fields!Group1.Value,"")

table1_Group1, no page breaks, group expression =Fields!Group1.Value

table1_Group2pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP2",Fields!Group2.Value,"")

table1_Group2, no page breaks, group expression =Fields!Group2.Value

Here is the data set I created for testing.

select 'ABC' as Group1, '123' as Group2, 'slfje' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'redfg' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'wqsde' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'rdrgd' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'f5e4s6' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'rhfth' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'effgfg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'kuhjg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'efjklrg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'euurio' as Data
union all
select 'DEF' as Group1, '654' as Group2, 'wesdf' as Data
union all
select 'GHI' as Group1, '789' as Group2, 'yghfg' as Data
union all
select 'GHI' as Group1, '789' as Group2, '56215hh' as Data
union all
select 'GHI' as Group1, '456' as Group2, 'hbvfg' as Data
union all
select 'GHI' as Group1, '456' as Group2, 't456e4w' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'ouuyf' as Data
union all
select 'GHI' as Group1, '123' as Group2, '5f4g8r9' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'zzzzzzzz' as Data

|||

Thank you for taking such care to provide a reproducible sample. I will check this out and write back, whether I can do this or not, and I have no idea at the moment <s>. I do know that it's a chancey thing, and it's often tricky to get the conditional expressions right, so I usually take a while to get it to work.

Anyway, I'll give this a shot and report back...

>L<

|||

OK -- you can do this, it will work <s>. What you're missing (I think) is that you have to put the conditionals on the outer rim of the "real" groups. IOW, your group order is this:

Group1pre

Group1

Group2pre

Group2

... and it is quite possible that it would have worked something like this:

Group1pre

Group2pre

Group1

Group2

... although I didn't try it that way.

What I did try successfully, and what appears to follow the "rules of engagement" as I understand them (my understanding being without inside knowledge, just observation, and is admittedly imperfect!), is this:

GroupsPre

Group1

Group2

... using the following expression as my conditional break on GroupsPre:

Code Snippet


=IIF(Parameters!PageBreak.Value="NONE","",

IIF(Parameters!PageBreak.Value="GROUP1",
Fields!Group1.Value,

Fields!Group2.Value)
)

I want to say one other thing, based on your sample data -- which may be compounded in something you're doing in your "real" data set:

I am not sure what effect you are after on the inner group break, but you may have to dynamically sort your data to get the effect you are after when the break is on "GROUP2" (your inner group as expressed in the report). It is certainly possible to do this, of course, and I'm not even sure that is an issue for you.

[LSN Editing next morning: instead of dynamic orderng you can probably concatenate the value in the last part of the expression as csi_hugh shows in the next post]

Regards,

>L<

Conditional page breaks in SSRS

Hi,

I am having trouble setting conditional page breaks to my reports.

i.e... I am having a report where I need to allow user the option to set page break between a group or not.

Based upon the option selected by the user, I need to add page break to the report. I tried with all possibilities inside Sort and Group dialog box, but could not figure out how to toggle the option at runtime.

Does anyone know how to implement page breaks on runtime? Help me plzzzz!! I really need this to be done…Thanx in advance for any help..

- Rayz

OK, I think I have succeeded in doing this...

create a boolean parameter, something like PageBreak --
I would give it a default value, but it doesn't appear to be necessary if you don't want it.
create a group with "page break at end", as you normally would. Don't put anything in its header and footer lines.
here's the trick: make this group's grouip expression an IIF() containing your "real" group expression,
something like the following example:|||

I tried it out ..but no luck for me

Wherever i apply page break..it seems it wont take the condition that i've specified..and pagebreaks appears permanently..even if i dont put pagebreak no..the page break comes..

Thanks for your suggestion

-Rayz

|||

Well, let's see...

>>it seems it wont take the condition that i've specified..and pagebreaks appears permanently

What is the condition you've specified?

Also, to make sure I can repro, is this an RDL or RDLC?

>L<

|||Perhaps you should extend the syntax that Lisa has shown with the IIF() function. If you set the group expression as previously mentioned and add a field reference that is global to the report instead of the empty field ( "" ) then perhaps this evaluate correctly.

=IIF(Parameters!PageBreak.Value, Fields!MyField.Value, Fields!MyMostGlobalField.Value)

This way you will get a field reference to evaluate the grouping to. You may additionally want to hide this group with a "Visibility" expression on the group, though you may still get a page break before your report footer if one exists.

Hope this helps.

-Paul R.
|||

Hi Paul,

It actually does work fine with the "" -- and in the past I've done this with other "global/invariant" expressions -- such as True or 1. Is there some reason why this is a bad idea?

BTW another way I do this, without an IIF(), is to group on a variable and increment the variable in code when I want to force a page break -- I haven't tried that in RS and it can be a little more difficult to manage in general. So I didn't try it in response to this query. I will try it if you think it's a better idea.


Regrads,

>L<

|||

Thanx a bunch Lisa....

ur initial suggestion worked !!

|||

Thanks for confirming!

>L<

|||

Hi,

I have five tables in a report which has to be repeated on every sheet of excel based on a variable

Can i also use the same condition?

Kindly help me out.

Thanks in advance

Nalini

|||

"Every sheet of Excel" is basically "every explicitly-requested page of the report". By that I mean you get a sheet for each page break you explicitly asked for with a page break condition, rather than the report just deciding that it has to page break based on some constraints of the host format (for example, physical page size).

So, "Excel" shouldn't be handled specifically when trying to repeat tables -- it should work the way you want, if you get the explicit page break requests correct.

I will assume you understand this (I almost wrote "that we're on the same page" <g>) and ignore the "Excel" part of the question...

So, you want to have five tables that you want to see on each page. Can you tell me some more about your layout, what each of the tables represent from the point of view of datasets? Are they related to each other or completely distinct, data-wise? Is there additional data in the report? are the tables positioned adjacent to each other vertically, or horizontally, or what?

>L<

|||

Lisa, I tried your approach and found two problems that I still can't figure out.

1) I had to do the Page break before the sections rather than after section in order for it to work.

2) I need to be able to choose the group level to page break on OR choose that no page break occurs at all. In this pursuit, I can't find a solution. Even if the Parameter!PageBreak criteria is not met, the top level group always page breaks. I need the ability to eliminate the page break as one of my options.

Any ideas?

|||

Well, it definitely does work and should not require page break before -- in fact using page break before might be why you're saying "top level always breaks".

I am not on a machine where I have any of these examples, and, clearly, we need to take this from the top.

Can I have a clear(er) statement of exactly what you've done so far in this report and also a separate statement of what the requirements are? This would optimally include some simplified SELECT or other way that I can repro exactly what your group breaks look like, there may be some collision that we have to account for that wasn't in the original suggestion (or maybe the collision *can't* be accounted for in your situation -- right now I honestly have no idea).

I'm leaving for the day now, so no rush on your response <s>

>L<

|||

I just created a stripped down sample report, and the issue with using page break after went away, but the other issue remains. I have a parameter named PageBreak with three option values: NONE, GROUP1, and GROUP2. When i choose NONE, it should always evaluate the Group1pre and Group2pre as ="" and therefore never cause a page break during the report. Unfortunately, it still causes the GROUP1 page breaks even if I choose NONE.

I created four group levels sequenced as follows (as seen in the Groups tab of Table Properties) and a detail row with the Detail values:

table1_Group1pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP1",Fields!Group1.Value,"")

table1_Group1, no page breaks, group expression =Fields!Group1.Value

table1_Group2pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP2",Fields!Group2.Value,"")

table1_Group2, no page breaks, group expression =Fields!Group2.Value

Here is the data set I created for testing.

select 'ABC' as Group1, '123' as Group2, 'slfje' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'redfg' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'wqsde' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'rdrgd' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'f5e4s6' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'rhfth' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'effgfg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'kuhjg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'efjklrg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'euurio' as Data
union all
select 'DEF' as Group1, '654' as Group2, 'wesdf' as Data
union all
select 'GHI' as Group1, '789' as Group2, 'yghfg' as Data
union all
select 'GHI' as Group1, '789' as Group2, '56215hh' as Data
union all
select 'GHI' as Group1, '456' as Group2, 'hbvfg' as Data
union all
select 'GHI' as Group1, '456' as Group2, 't456e4w' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'ouuyf' as Data
union all
select 'GHI' as Group1, '123' as Group2, '5f4g8r9' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'zzzzzzzz' as Data

|||

Thank you for taking such care to provide a reproducible sample. I will check this out and write back, whether I can do this or not, and I have no idea at the moment <s>. I do know that it's a chancey thing, and it's often tricky to get the conditional expressions right, so I usually take a while to get it to work.

Anyway, I'll give this a shot and report back...

>L<

|||

OK -- you can do this, it will work <s>. What you're missing (I think) is that you have to put the conditionals on the outer rim of the "real" groups. IOW, your group order is this:

Group1pre

Group1

Group2pre

Group2

... and it is quite possible that it would have worked something like this:

Group1pre

Group2pre

Group1

Group2

... although I didn't try it that way.

What I did try successfully, and what appears to follow the "rules of engagement" as I understand them (my understanding being without inside knowledge, just observation, and is admittedly imperfect!), is this:

GroupsPre

Group1

Group2

... using the following expression as my conditional break on GroupsPre:

Code Snippet


=IIF(Parameters!PageBreak.Value="NONE","",

IIF(Parameters!PageBreak.Value="GROUP1",
Fields!Group1.Value,

Fields!Group2.Value)
)

I want to say one other thing, based on your sample data -- which may be compounded in something you're doing in your "real" data set:

I am not sure what effect you are after on the inner group break, but you may have to dynamically sort your data to get the effect you are after when the break is on "GROUP2" (your inner group as expressed in the report). It is certainly possible to do this, of course, and I'm not even sure that is an issue for you.

[LSN Editing next morning: instead of dynamic orderng you can probably concatenate the value in the last part of the expression as csi_hugh shows in the next post]

Regards,

>L<

Conditional page breaks in SSRS

Hi,

I am having trouble setting conditional page breaks to my reports.

i.e... I am having a report where I need to allow user the option to set page break between a group or not.

Based upon the option selected by the user, I need to add page break to the report. I tried with all possibilities inside Sort and Group dialog box, but could not figure out how to toggle the option at runtime.

Does anyone know how to implement page breaks on runtime? Help me plzzzz!! I really need this to be done…Thanx in advance for any help..

- Rayz

OK, I think I have succeeded in doing this...

create a boolean parameter, something like PageBreak --
I would give it a default value, but it doesn't appear to be necessary if you don't want it.
create a group with "page break at end", as you normally would. Don't put anything in its header and footer lines.
here's the trick: make this group's grouip expression an IIF() containing your "real" group expression,
something like the following example:|||

I tried it out ..but no luck for me

Wherever i apply page break..it seems it wont take the condition that i've specified..and pagebreaks appears permanently..even if i dont put pagebreak no..the page break comes..

Thanks for your suggestion

-Rayz

|||

Well, let's see...

>>it seems it wont take the condition that i've specified..and pagebreaks appears permanently

What is the condition you've specified?

Also, to make sure I can repro, is this an RDL or RDLC?

>L<

|||Perhaps you should extend the syntax that Lisa has shown with the IIF() function. If you set the group expression as previously mentioned and add a field reference that is global to the report instead of the empty field ( "" ) then perhaps this evaluate correctly.

=IIF(Parameters!PageBreak.Value, Fields!MyField.Value, Fields!MyMostGlobalField.Value)

This way you will get a field reference to evaluate the grouping to. You may additionally want to hide this group with a "Visibility" expression on the group, though you may still get a page break before your report footer if one exists.

Hope this helps.

-Paul R.
|||

Hi Paul,

It actually does work fine with the "" -- and in the past I've done this with other "global/invariant" expressions -- such as True or 1. Is there some reason why this is a bad idea?

BTW another way I do this, without an IIF(), is to group on a variable and increment the variable in code when I want to force a page break -- I haven't tried that in RS and it can be a little more difficult to manage in general. So I didn't try it in response to this query. I will try it if you think it's a better idea.


Regrads,

>L<

|||

Thanx a bunch Lisa....

ur initial suggestion worked !!

|||

Thanks for confirming!

>L<

|||

Hi,

I have five tables in a report which has to be repeated on every sheet of excel based on a variable

Can i also use the same condition?

Kindly help me out.

Thanks in advance

Nalini

|||

"Every sheet of Excel" is basically "every explicitly-requested page of the report". By that I mean you get a sheet for each page break you explicitly asked for with a page break condition, rather than the report just deciding that it has to page break based on some constraints of the host format (for example, physical page size).

So, "Excel" shouldn't be handled specifically when trying to repeat tables -- it should work the way you want, if you get the explicit page break requests correct.

I will assume you understand this (I almost wrote "that we're on the same page" <g>) and ignore the "Excel" part of the question...

So, you want to have five tables that you want to see on each page. Can you tell me some more about your layout, what each of the tables represent from the point of view of datasets? Are they related to each other or completely distinct, data-wise? Is there additional data in the report? are the tables positioned adjacent to each other vertically, or horizontally, or what?

>L<

|||

Lisa, I tried your approach and found two problems that I still can't figure out.

1) I had to do the Page break before the sections rather than after section in order for it to work.

2) I need to be able to choose the group level to page break on OR choose that no page break occurs at all. In this pursuit, I can't find a solution. Even if the Parameter!PageBreak criteria is not met, the top level group always page breaks. I need the ability to eliminate the page break as one of my options.

Any ideas?

|||

Well, it definitely does work and should not require page break before -- in fact using page break before might be why you're saying "top level always breaks".

I am not on a machine where I have any of these examples, and, clearly, we need to take this from the top.

Can I have a clear(er) statement of exactly what you've done so far in this report and also a separate statement of what the requirements are? This would optimally include some simplified SELECT or other way that I can repro exactly what your group breaks look like, there may be some collision that we have to account for that wasn't in the original suggestion (or maybe the collision *can't* be accounted for in your situation -- right now I honestly have no idea).

I'm leaving for the day now, so no rush on your response <s>

>L<

|||

I just created a stripped down sample report, and the issue with using page break after went away, but the other issue remains. I have a parameter named PageBreak with three option values: NONE, GROUP1, and GROUP2. When i choose NONE, it should always evaluate the Group1pre and Group2pre as ="" and therefore never cause a page break during the report. Unfortunately, it still causes the GROUP1 page breaks even if I choose NONE.

I created four group levels sequenced as follows (as seen in the Groups tab of Table Properties) and a detail row with the Detail values:

table1_Group1pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP1",Fields!Group1.Value,"")

table1_Group1, no page breaks, group expression =Fields!Group1.Value

table1_Group2pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP2",Fields!Group2.Value,"")

table1_Group2, no page breaks, group expression =Fields!Group2.Value

Here is the data set I created for testing.

select 'ABC' as Group1, '123' as Group2, 'slfje' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'redfg' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'wqsde' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'rdrgd' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'f5e4s6' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'rhfth' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'effgfg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'kuhjg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'efjklrg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'euurio' as Data
union all
select 'DEF' as Group1, '654' as Group2, 'wesdf' as Data
union all
select 'GHI' as Group1, '789' as Group2, 'yghfg' as Data
union all
select 'GHI' as Group1, '789' as Group2, '56215hh' as Data
union all
select 'GHI' as Group1, '456' as Group2, 'hbvfg' as Data
union all
select 'GHI' as Group1, '456' as Group2, 't456e4w' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'ouuyf' as Data
union all
select 'GHI' as Group1, '123' as Group2, '5f4g8r9' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'zzzzzzzz' as Data

|||

Thank you for taking such care to provide a reproducible sample. I will check this out and write back, whether I can do this or not, and I have no idea at the moment <s>. I do know that it's a chancey thing, and it's often tricky to get the conditional expressions right, so I usually take a while to get it to work.

Anyway, I'll give this a shot and report back...

>L<

|||

OK -- you can do this, it will work <s>. What you're missing (I think) is that you have to put the conditionals on the outer rim of the "real" groups. IOW, your group order is this:

Group1pre

Group1

Group2pre

Group2

... and it is quite possible that it would have worked something like this:

Group1pre

Group2pre

Group1

Group2

... although I didn't try it that way.

What I did try successfully, and what appears to follow the "rules of engagement" as I understand them (my understanding being without inside knowledge, just observation, and is admittedly imperfect!), is this:

GroupsPre

Group1

Group2

... using the following expression as my conditional break on GroupsPre:

Code Snippet


=IIF(Parameters!PageBreak.Value="NONE","",

IIF(Parameters!PageBreak.Value="GROUP1",
Fields!Group1.Value,

Fields!Group2.Value)
)

I want to say one other thing, based on your sample data -- which may be compounded in something you're doing in your "real" data set:

I am not sure what effect you are after on the inner group break, but you may have to dynamically sort your data to get the effect you are after when the break is on "GROUP2" (your inner group as expressed in the report). It is certainly possible to do this, of course, and I'm not even sure that is an issue for you.

[LSN Editing next morning: instead of dynamic orderng you can probably concatenate the value in the last part of the expression as csi_hugh shows in the next post]

Regards,

>L<

Conditional page breaks in SSRS

Hi,

I am having trouble setting conditional page breaks to my reports.

i.e... I am having a report where I need to allow user the option to set page break between a group or not.

Based upon the option selected by the user, I need to add page break to the report. I tried with all possibilities inside Sort and Group dialog box, but could not figure out how to toggle the option at runtime.

Does anyone know how to implement page breaks on runtime? Help me plzzzz!! I really need this to be done…Thanx in advance for any help..

- Rayz

OK, I think I have succeeded in doing this...

create a boolean parameter, something like PageBreak --
I would give it a default value, but it doesn't appear to be necessary if you don't want it.
create a group with "page break at end", as you normally would. Don't put anything in its header and footer lines.
here's the trick: make this group's grouip expression an IIF() containing your "real" group expression,
something like the following example:|||

I tried it out ..but no luck for me

Wherever i apply page break..it seems it wont take the condition that i've specified..and pagebreaks appears permanently..even if i dont put pagebreak no..the page break comes..

Thanks for your suggestion

-Rayz

|||

Well, let's see...

>>it seems it wont take the condition that i've specified..and pagebreaks appears permanently

What is the condition you've specified?

Also, to make sure I can repro, is this an RDL or RDLC?

>L<

|||Perhaps you should extend the syntax that Lisa has shown with the IIF() function. If you set the group expression as previously mentioned and add a field reference that is global to the report instead of the empty field ( "" ) then perhaps this evaluate correctly.

=IIF(Parameters!PageBreak.Value, Fields!MyField.Value, Fields!MyMostGlobalField.Value)

This way you will get a field reference to evaluate the grouping to. You may additionally want to hide this group with a "Visibility" expression on the group, though you may still get a page break before your report footer if one exists.

Hope this helps.

-Paul R.
|||

Hi Paul,

It actually does work fine with the "" -- and in the past I've done this with other "global/invariant" expressions -- such as True or 1. Is there some reason why this is a bad idea?

BTW another way I do this, without an IIF(), is to group on a variable and increment the variable in code when I want to force a page break -- I haven't tried that in RS and it can be a little more difficult to manage in general. So I didn't try it in response to this query. I will try it if you think it's a better idea.


Regrads,

>L<

|||

Thanx a bunch Lisa....

ur initial suggestion worked !!

|||

Thanks for confirming!

>L<

|||

Hi,

I have five tables in a report which has to be repeated on every sheet of excel based on a variable

Can i also use the same condition?

Kindly help me out.

Thanks in advance

Nalini

|||

"Every sheet of Excel" is basically "every explicitly-requested page of the report". By that I mean you get a sheet for each page break you explicitly asked for with a page break condition, rather than the report just deciding that it has to page break based on some constraints of the host format (for example, physical page size).

So, "Excel" shouldn't be handled specifically when trying to repeat tables -- it should work the way you want, if you get the explicit page break requests correct.

I will assume you understand this (I almost wrote "that we're on the same page" <g>) and ignore the "Excel" part of the question...

So, you want to have five tables that you want to see on each page. Can you tell me some more about your layout, what each of the tables represent from the point of view of datasets? Are they related to each other or completely distinct, data-wise? Is there additional data in the report? are the tables positioned adjacent to each other vertically, or horizontally, or what?

>L<

|||

Lisa, I tried your approach and found two problems that I still can't figure out.

1) I had to do the Page break before the sections rather than after section in order for it to work.

2) I need to be able to choose the group level to page break on OR choose that no page break occurs at all. In this pursuit, I can't find a solution. Even if the Parameter!PageBreak criteria is not met, the top level group always page breaks. I need the ability to eliminate the page break as one of my options.

Any ideas?

|||

Well, it definitely does work and should not require page break before -- in fact using page break before might be why you're saying "top level always breaks".

I am not on a machine where I have any of these examples, and, clearly, we need to take this from the top.

Can I have a clear(er) statement of exactly what you've done so far in this report and also a separate statement of what the requirements are? This would optimally include some simplified SELECT or other way that I can repro exactly what your group breaks look like, there may be some collision that we have to account for that wasn't in the original suggestion (or maybe the collision *can't* be accounted for in your situation -- right now I honestly have no idea).

I'm leaving for the day now, so no rush on your response <s>

>L<

|||

I just created a stripped down sample report, and the issue with using page break after went away, but the other issue remains. I have a parameter named PageBreak with three option values: NONE, GROUP1, and GROUP2. When i choose NONE, it should always evaluate the Group1pre and Group2pre as ="" and therefore never cause a page break during the report. Unfortunately, it still causes the GROUP1 page breaks even if I choose NONE.

I created four group levels sequenced as follows (as seen in the Groups tab of Table Properties) and a detail row with the Detail values:

table1_Group1pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP1",Fields!Group1.Value,"")

table1_Group1, no page breaks, group expression =Fields!Group1.Value

table1_Group2pre, page break at end checked, group expression =IIF(Parameters!PageBreak.Value="GROUP2",Fields!Group2.Value,"")

table1_Group2, no page breaks, group expression =Fields!Group2.Value

Here is the data set I created for testing.

select 'ABC' as Group1, '123' as Group2, 'slfje' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'redfg' as Data
union all
select 'ABC' as Group1, '123' as Group2, 'wqsde' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'rdrgd' as Data
union all
select 'ABC' as Group1, '456' as Group2, 'f5e4s6' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'rhfth' as Data
union all
select 'ABC' as Group1, '789' as Group2, 'effgfg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'kuhjg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'efjklrg' as Data
union all
select 'DEF' as Group1, '987' as Group2, 'euurio' as Data
union all
select 'DEF' as Group1, '654' as Group2, 'wesdf' as Data
union all
select 'GHI' as Group1, '789' as Group2, 'yghfg' as Data
union all
select 'GHI' as Group1, '789' as Group2, '56215hh' as Data
union all
select 'GHI' as Group1, '456' as Group2, 'hbvfg' as Data
union all
select 'GHI' as Group1, '456' as Group2, 't456e4w' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'ouuyf' as Data
union all
select 'GHI' as Group1, '123' as Group2, '5f4g8r9' as Data
union all
select 'GHI' as Group1, '123' as Group2, 'zzzzzzzz' as Data

|||

Thank you for taking such care to provide a reproducible sample. I will check this out and write back, whether I can do this or not, and I have no idea at the moment <s>. I do know that it's a chancey thing, and it's often tricky to get the conditional expressions right, so I usually take a while to get it to work.

Anyway, I'll give this a shot and report back...

>L<

|||

OK -- you can do this, it will work <s>. What you're missing (I think) is that you have to put the conditionals on the outer rim of the "real" groups. IOW, your group order is this:

Group1pre

Group1

Group2pre

Group2

... and it is quite possible that it would have worked something like this:

Group1pre

Group2pre

Group1

Group2

... although I didn't try it that way.

What I did try successfully, and what appears to follow the "rules of engagement" as I understand them (my understanding being without inside knowledge, just observation, and is admittedly imperfect!), is this:

GroupsPre

Group1

Group2

... using the following expression as my conditional break on GroupsPre:

Code Snippet


=IIF(Parameters!PageBreak.Value="NONE","",

IIF(Parameters!PageBreak.Value="GROUP1",
Fields!Group1.Value,

Fields!Group2.Value)
)

I want to say one other thing, based on your sample data -- which may be compounded in something you're doing in your "real" data set:

I am not sure what effect you are after on the inner group break, but you may have to dynamically sort your data to get the effect you are after when the break is on "GROUP2" (your inner group as expressed in the report). It is certainly possible to do this, of course, and I'm not even sure that is an issue for you.

[LSN Editing next morning: instead of dynamic orderng you can probably concatenate the value in the last part of the expression as csi_hugh shows in the next post]

Regards,

>L<

Conditional Order by?

Is there a way to do a conditional order by so that a user can give a parameter to a stored proc and it give back results sorted the way they want?

I want it so that the user can do 1 of 4 things,
* sort by "title" ascending,
* sort by "title" descending,
* sort by "synopsis" ascending,
* sort by "synopsis" descending

Can it be done? This is what I have but I get a syntax error:

select * from Blah

Order By
Case
when @.orderId = 1 then title asc
when @.orderId = 2 then title desc
when @.orderId = 3 then synopsis asc
when @.orderId = 4 then synopsis desc
end

Any help is greatly appreciated!

You need to split the query as ASC Query & Desc Query.

You can choose your order by columns (if it is single column) dynamically but Sorting Order you can't.

Use your query as follow as

if @.OrderId in (1,3)

select * from Blah
Order By
Case
when @.orderId = 1 then title
when @.orderId = 3 then synopsis
end asc

else

select * from Blah
Order By
Case
when @.orderId = 2 then title
when @.orderId = 4 then synopsis
end Desc

Or

You can use dynamic SQL

Declare @.SQL as NVarchar(1000)

Select @.SQL = N'select * from Blah

Order By ' +
Case
when @.orderId = 1 then 'title asc'
when @.orderId = 2 then 'title desc'
when @.orderId = 3 then 'synopsis asc'
when @.orderId = 4 then 'synopsis desc'
end

Exec (@.SQL)

|||Why don't you dynamically add the final order by clause to the select query string ?
I guess it is more clear to understand and much more flexible for any future changes.|||Thanks both for the replies, I didnt know it would be so detailed, I have a rather large select query that I am applying this to and I dont really want to create a string then execute it, it just looks messy to me. But I guess if I have no option I guess ill have to.

Thanks again|||In some cases I have done this:

SELECT ....,
SortOrder = Case when @.orderId = 1 then title
when @.orderId = 2 then REVERSE(TITLE)
when @.orderId = 3 then synopsis
when @.orderId = 4 then REVERSE(synopsis) END
ORDER BY SortOrder

The only issue with this is all the vars in the CASE must be the same type, or cast to a certain type.

|||

Easiest is to do below:

order by

case @.orderId when 1 then title end

, case @.orderId when 2 then title end desc

, case @.orderId when 3 then synopsis end

, case @.orderId when 4 then synopsis end desc

Note that you will get the best performance (assuming you have indexes on the column(s) and the plan can use it) if you use dynamic SQL to form the ORDER BY with required columns or use different SELECT statements. But in most cases, I have found that the above construct is easier to use, safe from SQL injection (dynamic SQL is prone to it if you are not careful) and with few conversions which single CASE expression requires.

|||Thanks all for the help with this topic, I think Umachandar's answer will fit my solution best.

conditional inner join?

Im faced with the following design issue..

on my site there are different profiles: a city profile, a restaurant profile and a user profile.

in my DB:
City profiles are stored in tbCities
cityID int PK
shortname nvarchar(50)
forumID int FK
(...)

Restaurant profiles are stored in tbRests
restID int PK
shortname nvarchar(50)
forumID int FK
(...)

User profiles are stored in tbUsers
userID int PK
shortname nvarchar(50)
forumID int FK
(...)

as you can see a single ID value (for CityID,restID or userid) might occur in multiple tables (e.g. ID 12 may exist in tbRests and in tbUsers)
Each of these profile owners can start a forum on their profile.

forumID in each of the above tables is a FK to the PK in tbForums:
forumID int
forumname nvarchar(50)
(...)

Now imagine the following:

a site visitor searches ALL forums...say he finds the following forums:
ForumID Forumname
1 you opinion on politics
2 is there life in space?
3 who should be the next president of the USA?

a user may want to click on the forum name to go to the profile the forum belongs to.
And then there's a problem, because I dont know in which table I should look for the forum ID...
ORI would have to scan all tables (tbCities,tbRests and tbUsers) for that specific forumid,which is time-consuming andI dont want that!

so if a user would click on forumID 2 (is there life in space?)

I want to do a conditional inner join for the tablecontainingforumID (which may be tbCities,tbRests or tbUsers)

select tablecontainingforumID.shortname FROM tablecontainingforumID t
INNER JOIN tbForums f ON t.ForumID=f.ForumID
where f.ForumID=2


I hope my problem is clear..any suggestions are welcome (im even willing to change my DB design if that would increase effectivity)


Honestly here is your problem. You need to join up the table depending on which subTable contains the forum, the problem is you don't know the forum table ahead of time. So you are going to have to do this dynamically, or alternatively create a view which is a UNION of all those tables, and then join to the View. The question is which is going to perform better for you. The nice thing about Views is that like stored procs they are compiled. The bad thing is there are no indexes. So if you table is over a 10000 rows I would forget about the view. You can either use dynamic sql in a stored proc, or use a big case or if...else statement inorder to pick the correct join you want to do. Other than that I don't know what to tell you. The design of the database doesn't give you much flexability, especially since these table seem very close to each other as far as design. You may be able to combine them.|||One alternative is to divide your ID's across profiles as in 1-100000 IDs for cities, 200000+ for restaurants, 400000+ for users etc. So based on the ID you can directly join the particular table.|||

Or may be you could do it like this:

IF EXISTS( SELECT * From tblCities where forumid = @.forumid)

Begin

-- Join with tblCities

SELECT * from tblforums TF JOIN tblCities TC on ......

End

Else IF Exists (SELECT * FROM TblRests Where forumid = @.forumid)

Begin

-- Join with tblrests

End

and so on..

|||

hmmm...IMHO...your first solution is quicker...but design technical it seems that the second solution is better (also with scalability in mind)

but with say 5000000 user profiles and 500000 restaurant profiles and 1000000 city profiles...what would you advice?

|||

Is it possible to designate from the Forum table which table to look in?

What this means is that you add another column to the Forum table and set the values equal to city or restaurant or user. Then you can use a simple switch statement like the one above to switch between the different lookups you need to do.

On the flip side you could combine all three tables, give the unqiue column amount the three a common ID name, and set a field that tells what other table it should look at. That way you are only joining against one table.

Or you could just combine both ways above and merge everything in to the Forum table including the shortname and the unique id.

However if you don't want to change your current schema, I would index the ForumID's and just check if the ID exists in each table. However make sure they are checked in order or which one gets hit the most. So if you city table gets hit the most put it as the first check, so that you won't have to check through the other tables.

Basically there are many solutions, you just need to find that one that works best for you.

|||The first one would work but there are some caveats. You have to be able to see well into future and take a good guess about the number of records the table might have. So you dont cross over into the next bracket. Lets say you allocate 1-100000 to cities and 1000001-500000 to restaurants. There could be a situation where you have more cities and one day reach the 100000th mark and you will be left out of numbers. Of course you could still be a little create and assign another batch of numbers say from 800000-900000 but you would have to change your code again. I would prefer my second solution which does not involve changing data. Also, as nberardi mentioned, make sure you have proper indexes and you could line up the tables in the order in which they are likely to get hit first.

Wednesday, March 7, 2012

conditional grouping (to group or not to group)

I have 3 groups: region, district, facility.
Depending upon user input, I want to either display the data in a drilldown
such as:
region 1
district 1
facility A data data data
facility C data data data
facility F data data data
district 2
facility B
facility D
...etc
or I want to only display the facility data without the drilldown and
without displaying which region and district those facilities belong to.
Obviously, this could be done by using 2 separate reports, but I need to have
this functionality for all of my reports. So if there is a simple way to
allow for it in the same report, I would like to do that.
ThanksThe closest you can get is a conditional grouping expression like this:
=iif(Parameters!GroupOnRegion.Value = True, Fields!Region.Value, 1)
Note: Grouping on a constant value will just generate 1 group that contains
all values.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Stads" <Stads@.discussions.microsoft.com> wrote in message
news:CC17E391-B188-492F-980E-C8F3B4298F97@.microsoft.com...
> I have 3 groups: region, district, facility.
> Depending upon user input, I want to either display the data in a
drilldown
> such as:
> region 1
> district 1
> facility A data data data
> facility C data data data
> facility F data data data
> district 2
> facility B
> facility D
> ...etc
> or I want to only display the facility data without the drilldown and
> without displaying which region and district those facilities belong to.
> Obviously, this could be done by using 2 separate reports, but I need to
have
> this functionality for all of my reports. So if there is a simple way to
> allow for it in the same report, I would like to do that.
> Thanks
>

Conditional group by

Hi,

Can anyone help me in writing this sql query, i want to group my select statement depending on the parameter user is passing.

Say when @.group='Cell' I want to group by CellID otherwise different conditions, something like below query but it is not working. I know we can't use case directly in where but please let me know if there is any other work around.

I don't want to use dynamic query and also this is big SP so i dont want to break sp in four conditions.

declare @.group varchar(10)

set @.group='Cell'

select cellid,sum(count)

FROM CellImpressionFact

WHERE ImpressionTypeLevelId = 2

AND ImpressionTypeId = 4

group by

case when group='Cell' then GROUP BY CellId

else group by activityID

end

This is not a good idea really. I would use dynamic SQL to provide this kind of capability if you really need to. It is possible (see code) but I would be very concerned about performance.


create table test
(
grouper int,
grouper2 int,
value decimal(10,5)
)
go
insert into test
select 1,1,10
union all
select 1,2,10
union all
select 1,3,10
union all
select 2,1,10
go
declare @.groupby varchar(10)
set @.groupBy = 'grouper2'

select max(grouper) as grouper,
max(grouper2) as grouper2,
sum(value) as valueSum
from test
group by case when @.groupBy = 'grouper' then grouper else grouper2 end

Note that the grouper2 column is of any value when you group by grouper, and vice versa (say it five times fast.)

Conditional formatting on drill down

I have a report that when the user drills down I need to change the formatting to include borders and/or colours. I tried adding the following statement to top border of the element without luck. Since I don't know when the detail is the last line of the drop down, I am uncertain how to try adding it there.

I do not want the underline to show when there is no expanded drill down.

=iif((Previous(Level) > 0, "Dotted", "None")

g1 name1 total1

g1 name2 total2

d po#3a total3a

d po#3b total3b <<-- want to add underline between total3b and total3

g1 name3 total3

Thank you

Just a quick stab...but couldn't you include the "underline" as a border on the top of your "g1 name total3" line as opposed to on the bottom of the last subtotal? That way it looks like it's rendering on the lowest one, but in reality it's not.

|||

I'm sorry I wasn't clear enough. I need the correct statement to go on the border style TOP of the g1 entry so that it will only show when there is a drill down.

I have tried "=iff((previous(level)) > 0), "Dotted", "None")" however it did not work. Along with variations on a theme.

Conditional Formatting - Export

Using the web viewer control in VS 2005, is there a way to conditionally format items for export only?

For example, user runs a report which gets displayed in the viewer. The report contains small images and or decorated text for links to additional reports. If user selects pdf from the export dropdown list and clicks export, I would like hide the images in the pdf and or format the decorated text differently.

If the answer is no, is it due to the report already being in its intermediate state?

The answer to your first question is no. One way of getting close to the desired behavior is to either use different report definitions or use a report parameter to determine if images should be shown etc.

The answer to the second question is yes. When you export the report to PDF, it will just re-render the report from the already processed (and output-format independent) intermediate format.

-- Robert

Saturday, February 25, 2012

Conditional For Insert Trigger

Sort of new to this, hoping for some help here.
I've got a table which you insert Scores and comments for Different
Issues. Each User may only input ONE score, but many comments per
issue.
I'm attempting to run a trigger which looks at the distinct users (in
the table) and then will either allow the comment AND score to be
Inserted if the User hasn't put in a score for that issue yet. OR if
the User already HAS input a Score, set the Score to NULL and allow the
rest of the record to be inserted.
My trigger works, but instead of letting the *New* User to put in the
score, it just nulls it.
Sorry if this is kind of long, but I hope I've explained it
sufficiently. I hope someone can help me out. Thanks in advance
This is my trigger :
CREATE TRIGGER trCheckUserResponses
ON dbo.tblIssues_Responses
FOR INSERT
AS
IF (SELECT UserID from Inserted) not in (select distinct UserID from
tblIssues_responses)
BEGIN
Update tblIssues_Responses
Set tblIssues_Responses.Score= Inserted.Score
From tblIssues_Responses AS A, Inserted AS B
Where A.Response_ID = B.Response_ID
END
ELSE
BEGIN
Update tblIssues_Responses
Set tblIssues_Responses.Score = NULL
From tblIssues_Responses AS A, Inserted AS B
Where A.Response_ID = B.Response_ID
ENDPlease post DDL and sample data.
ML
http://milambda.blogspot.com/

Conditional execution of first task

I have a situation where I'd like to conditionally execute the first task in a package based on the contents of a user variable.

If user variable "Var1" is false I want to begin execution with the first task.

If "Var1" is true I want to begin execution at the second task.

My first thought of course was SequenceContainer, but the same issue would exist for the first task in a SequenceContainer.

Is there a way to do this?

Thanks!

To conditionally execute a task you would use a constraint with an expression on it, but you need two tasks (containers) to do this. The ideal answer is to use something that does nothing, but offers a start point for the constraint. A sequence container works rather well, just drop it on and collpase it (the arrow on the right-hand side of the header). You can then link that to the real task, nothing should go inside that sequence container.|||

I have created a sample solution inline with Darren's suggeston to use 'Sequence Container' for placing the precedence condition @. http://mystutter.blogspot.com/2006/03/sql-server-integration-services.html

Please let me know your comments.

Thanks,
Loonysan

|||

Thank you. Your example was perfect.

I found another solution as well. I created a Sequence Container, inside that I created another Sequence Container and my first task. I put an expression constraint between those. Then I linked the outer Sequence Container to the second task.

I appreciate the help.