Wednesday, March 21, 2012
Group Total Not working right
I have a problem that i cannot figure out how to fix.
I have a sub report that i need to have the group totals in the Page header and i cannot for the life of me remember how to do this.
I have grouped by field 2 which gives me a time for Planned and unplanned events, I need to add up the time of the Planned items and put next to my Downtime Planned Text Box, and then sum the Unplanned and do the same against my unplanned downtime box
Regards SteveExample:
subreport 1 formula:
whileprintingrecords;
shared numbervar x:= sum({table.field})
subreport 2 formula:
whileprintingrecords;
shared numbervar y:= sum({table.field})
Formula in the main report:
whileprintingrecords;
shared numbervar x;
shared numbervar y;
x+y|||just to add some thing. You can use the sum function as
sum({table.field}, "Group on the field");
So you can get the planned and unplanned in the same subreport.|||Very confused with First reply, but will have a go at that, Second reply worked fine fo the same report
Regards
Steve
Monday, March 19, 2012
Group Name in Page Header
in the page header (I'm also inserting a page break at the end of each
group). Is this possible?Yes this is possible in your case. Assuming you have a textbox called
GroupName in the grouping header which shows the current value of the
grouping, you can just add another textbox in the page header which
references the value of the GroupName textbox:
=ReportItems!GroupName.Value
Note: only the ReportItems collection is accessible in the page
headers/footers, but not the Fields collection.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"J Chang" <julia.chang@.maritz.com> wrote in message
news:946c3e64.0410221341.3018ec18@.posting.google.com...
> When using Grouping, I need to display the value of the grouped field
> in the page header (I'm also inserting a page break at the end of each
> group). Is this possible?
Group Heading text different on repeated headers
Is there any way to have the data displayed in a group header different on the first occurrence of the header from subsequent occurrences within that same group?
I have the Repeat Header option checked, so the header appears on every page. I want the pages where it is a continuation (has been repeated because the option is on) to look different, e.g., the group's name cell should be "<name> (cont.)", where on the first page it appears it should be just "<name>". I can use an expression in a cell in the header, but I don't see any convenient function or other way to detect whether this is the first, or a subsequent, instance of the header.
I thought of using the RowNumber function, scoped to the header grouping, but this seems to return the row number of the bottom-most (last) detail row of the group - that is, the number of rows in the group - so that doesn't seem to help.
Have you found any solution to the issue in your post? I would like to do the same on a grouped table report and cannot seem to find the key.Group Heading text different on repeated headers
Is there any way to have the data displayed in a group header different on the first occurrence of the header from subsequent occurrences within that same group?
I have the Repeat Header option checked, so the header appears on every page. I want the pages where it is a continuation (has been repeated because the option is on) to look different, e.g., the group's name cell should be "<name> (cont.)", where on the first page it appears it should be just "<name>". I can use an expression in a cell in the header, but I don't see any convenient function or other way to detect whether this is the first, or a subsequent, instance of the header.
I thought of using the RowNumber function, scoped to the header grouping, but this seems to return the row number of the bottom-most (last) detail row of the group - that is, the number of rows in the group - so that doesn't seem to help.
Have you found any solution to the issue in your post? I would like to do the same on a grouped table report and cannot seem to find the key.Group Headers
Is there a way to Drill down and not to show the Group header details.
Thanks
Prashtry suppressing the group header
Group header won't repeat
page, even if the group spans more than one page.
-In the Visual Studio preview the same group header won't repeat
on every page.
-In the Reporting services HTML preview the group header WILL
repeat on every page (even if the group is the same).
-Exporting the report to PDF format won't repeat the List's Group Header
on every page.
I have Reporting services and Visual Studio 2003.I ran Reporting services
SP2 on all machines.Hi there
U can use the TableRow Property: RepeatOnNewPage=True In the Layout section.
"FattoreK" wrote:
> I have a report with a List with Group Headers i want to repeat on every
> page, even if the group spans more than one page.
> -In the Visual Studio preview the same group header won't repeat
> on every page.
> -In the Reporting services HTML preview the group header WILL
> repeat on every page (even if the group is the same).
> -Exporting the report to PDF format won't repeat the List's Group Header
> on every page.
> I have Reporting services and Visual Studio 2003.I ran Reporting services
> SP2 on all machines.|||we don't use table, but "list".
the problem is that the group header repeats in preview and html mode,
but doesn't do it in pdf mode.
"ש×?×?×?" wrote:
> Hi there
> U can use the TableRow Property: RepeatOnNewPage=True In the Layout section.
> "FattoreK" wrote:
> > I have a report with a List with Group Headers i want to repeat on every
> > page, even if the group spans more than one page.
> >
> > -In the Visual Studio preview the same group header won't repeat
> > on every page.
> > -In the Reporting services HTML preview the group header WILL
> > repeat on every page (even if the group is the same).
> > -Exporting the report to PDF format won't repeat the List's Group Header
> > on every page.
> >
> > I have Reporting services and Visual Studio 2003.I ran Reporting services
> > SP2 on all machines.
group header visibility problem
I want my data to look something like this:
-Group1_master data - header1
-Group1_master data - some description - header2
-Details of group1.....
Now, i want to display this header2 only if descrpition contains data, that
is not null, and i wrote expression like this:
=Iif(Fields!Description.Value = Nothing, "True", "False")
.. and put it in the Hidden property of table row that is actualy ma header2
But that header2 is never hidden, i realy dont know is that a known problem
or im missing something.
tnx for any replaysTry changing "True" to true and "False" to false:
=iif(Fields!Description.Value = Nothing, true, false)
Bruce Johnson [MSFT]
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"hypo vedran" <hypo vedran@.discussions.microsoft.com> wrote in message
news:1B43308B-2A2B-4571-8BAE-4031C6CEC62A@.microsoft.com...
> I have table with two group headers.
> I want my data to look something like this:
> -Group1_master data - header1
> -Group1_master data - some description - header2
> -Details of group1.....
> Now, i want to display this header2 only if descrpition contains data,
that
> is not null, and i wrote expression like this:
> =Iif(Fields!Description.Value = Nothing, "True", "False")
> .. and put it in the Hidden property of table row that is actualy ma
header2
> But that header2 is never hidden, i realy dont know is that a known
problem
> or im missing something.
> tnx for any replays
Group Header to next page
In my Crystal Report generated with VB6.0, I have added a Group Header on to the Report. This is followed by another group in the Report, all done with coding. I would like to know if I can print the report in such a way, that the 2 two groups should always be together. At times it so happens that the first group will be in one page and the next group will be in the next page. It would be easier for the user to understand the report if the groups are together. Can this be accomplished?
ThanksHi,
Explain your requirements with diagrams (examples), so that developers can understand your requirement properly.
Thanks.
Hi,
In my Crystal Report generated with VB6.0, I have added a Group Header on to the Report. This is followed by another group in the Report, all done with coding. I would like to know if I can print the report in such a way, that the 2 two groups should always be together. At times it so happens that the first group will be in one page and the next group will be in the next page. It would be easier for the user to understand the report if the groups are together. Can this be accomplished?
Thanks
Group Header Repeating issue
Hi,
I have a group header and I have a invisible textbox which initializes some variable in the custom code (written using C#). The Group Header has been set to repeat on each page but whenever it repeats, the variable is not being initialized. It is initialized only when a new section of the same group starts. Please let me know if this is a drawback with Microsoft reporting services and if there is any workaround.
Thanks,
Shyam
Hi Shyam
I'm don't know if the hidden textbox is in the group header,
in the case that is is not:
Try putting the Initialization code into a hidden column in the groupHeader,
it should solve your problem.
Gerhard Davids
|||The group header has just one rectangle and many textboxes inside it. One of the textboxes is hidden which is used to initialize the variable in custom code. I tried to put the same in another new column which is hidden but it did not work. But in crystal reports, the initialization code is invoked everytime a group header is displayed either in a new page as a new group.
Thanks,
Shyam
|||I've Tried this out and couldnt get it working.
This is a sticky Problem, maby see if it is not possible to get it into the Page header instead.
It may be that the header isn't redone on every page simply re-displayd,
Where as the page header i think is different.
Gerhard
Group Header Question
GA
xxxxx xxxxx xxxxx xxxx
xxxxx xxxxx xxxxx xxxx
When the page breaks and it is still on the same group, is there away to
make the group head look like this:
GA (cont'd)
xxxxx xxxxx xxxxx xxxx
xxxxx xxxxx xxxxx xxxx
Thanks in advanceThe table group header has a property for "RepeatOnNewPage". Set it to true,
and the group header will repeat.
However, you can't add the "(cont'd)" string in that case, because all
repeated group headers will be identical to the initial one.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"OriginalStealth" <OriginalStealth@.discussions.microsoft.com> wrote in
message news:67476532-6565-4426-9151-EE5107867ABD@.microsoft.com...
>I have a report that list information for each city by state as shown
>below.
> GA
> xxxxx xxxxx xxxxx xxxx
> xxxxx xxxxx xxxxx xxxx
> When the page breaks and it is still on the same group, is there away to
> make the group head look like this:
> GA (cont'd)
> xxxxx xxxxx xxxxx xxxx
> xxxxx xxxxx xxxxx xxxx
> Thanks in advance|||why can't this be done with a list as well?
"Robert Bruckner [MSFT]" wrote:
> The table group header has a property for "RepeatOnNewPage". Set it to true,
> and the group header will repeat.
> However, you can't add the "(cont'd)" string in that case, because all
> repeated group headers will be identical to the initial one.
>
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "OriginalStealth" <OriginalStealth@.discussions.microsoft.com> wrote in
> message news:67476532-6565-4426-9151-EE5107867ABD@.microsoft.com...
> >I have a report that list information for each city by state as shown
> >below.
> >
> > GA
> > xxxxx xxxxx xxxxx xxxx
> > xxxxx xxxxx xxxxx xxxx
> >
> > When the page breaks and it is still on the same group, is there away to
> > make the group head look like this:
> >
> > GA (cont'd)
> > xxxxx xxxxx xxxxx xxxx
> > xxxxx xxxxx xxxxx xxxx
> >
> > Thanks in advance
>
>
Group header printed unnecessarily on page because no rows below
printed at the bottom of the page (when exported to PDF) with no rows below
it. The following page printed the group header again with the rows.
Is there a way to stop that behaviour?
Example...
Page1.
Group Header
Row
Row
Group Footer
Group Header <<< this printed unnecessarily
Page 2
Group Header
Row
Group Footer
--
McGeeky
http://mcgeeky.blogspot.comStill no workaround for this? I hate, hate , hate telling my users they just
have to deal with it.
"McGeeky" wrote:
> I am using a table with grouping - but found that the group header was
> printed at the bottom of the page (when exported to PDF) with no rows below
> it. The following page printed the group header again with the rows.
> Is there a way to stop that behaviour?
> Example...
> Page1.
> Group Header
> Row
> Row
> Group Footer
> Group Header <<< this printed unnecessarily
> Page 2
> Group Header
> Row
> Group Footer
> --
> McGeeky
> http://mcgeeky.blogspot.com
>
>
Group Header Alternating color
I am trying to get alternating colors on group headers.
The rownumber() doesn't work; that only seems to be the count of rows in the group.
Does anyone have any great ideas for this?
Thanks!
BobP
Have you tried CountDistinct(<group expression fields>)?|||Yes, I get a "1" for each group header row.
I have also tried countrows.
BobP
|||I realize this was a year ago, but was wondering if anyone had figured out a solution. I am trying to alternate colors at the group level and am not having any luck...|||
If I understand you correctly, this should give you the desired result:
Add this to your code window:
Code Snippet
Dim numFooterRow as Double
Function GetRowNumber() as Double
numFooterRow += 1
Return numFooterRow
End Function
Add a new column to the table and mark it as not visible. On the group header row (the invisible column), add this expression:
Code Snippet
=Code.GetRowNumber()You will need the name of the textbox that you just entered the expression into for the final part. In the header row background color add the following expression:
Code Snippet
=iif(ReportItems!textbox18.Value Mod 2 = 0,"LightCoral","RosyBrown")You now have alternating colors at the group header level.
Simone
|||I am trying to do something where I say look through the row. When you come across the word "Start" color that box green and color all other boxes to the right in that row green as well until you come upon the word "stop". Is this possible? If I am not making sense just let me know and I will try to explain better. Thanks in advance for any help that I get.|||You might want to start a new thread, although somewhat similar, it seems to me its a different topic...|||Ok will do.
Group Header Alternating color
I am trying to get alternating colors on group headers.
The rownumber() doesn't work; that only seems to be the count of rows in the group.
Does anyone have any great ideas for this?
Thanks!
BobP
Have you tried CountDistinct(<group expression fields>)?|||Yes, I get a "1" for each group header row.
I have also tried countrows.
BobP
|||I realize this was a year ago, but was wondering if anyone had figured out a solution. I am trying to alternate colors at the group level and am not having any luck...|||
If I understand you correctly, this should give you the desired result:
Add this to your code window:
Code Snippet
Dim numFooterRow as Double
Function GetRowNumber() as Double
numFooterRow += 1
Return numFooterRow
End Function
Add a new column to the table and mark it as not visible. On the group header row (the invisible column), add this expression:
Code Snippet
=Code.GetRowNumber()You will need the name of the textbox that you just entered the expression into for the final part. In the header row background color add the following expression:
Code Snippet
=iif(ReportItems!textbox18.Value Mod 2 = 0,"LightCoral","RosyBrown")You now have alternating colors at the group header level.
Simone
|||I am trying to do something where I say look through the row. When you come across the word "Start" color that box green and color all other boxes to the right in that row green as well until you come upon the word "stop". Is this possible? If I am not making sense just let me know and I will try to explain better. Thanks in advance for any help that I get.|||You might want to start a new thread, although somewhat similar, it seems to me its a different topic...|||Ok will do.
Group Header Alternating color
I am trying to get alternating colors on group headers.
The rownumber() doesn't work; that only seems to be the count of rows in the group.
Does anyone have any great ideas for this?
Thanks!
BobP
Have you tried CountDistinct(<group expression fields>)?|||Yes, I get a "1" for each group header row.
I have also tried countrows.
BobP
|||I realize this was a year ago, but was wondering if anyone had figured out a solution. I am trying to alternate colors at the group level and am not having any luck...|||
If I understand you correctly, this should give you the desired result:
Add this to your code window:
Code Snippet
Dim numFooterRow as Double
Function GetRowNumber() as Double
numFooterRow += 1
Return numFooterRow
End Function
Add a new column to the table and mark it as not visible. On the group header row (the invisible column), add this expression:
Code Snippet
=Code.GetRowNumber()You will need the name of the textbox that you just entered the expression into for the final part. In the header row background color add the following expression:
Code Snippet
=iif(ReportItems!textbox18.Value Mod 2 = 0,"LightCoral","RosyBrown")You now have alternating colors at the group header level.
Simone
|||I am trying to do something where I say look through the row. When you come across the word "Start" color that box green and color all other boxes to the right in that row green as well until you come upon the word "stop". Is this possible? If I am not making sense just let me know and I will try to explain better. Thanks in advance for any help that I get.|||You might want to start a new thread, although somewhat similar, it seems to me its a different topic...|||Ok will do.
Group Header
In my group header I have a cell that I want to display "the group number".
Ex.
Group A - 1
XXXXXXXXXX
Group B - 2
XXXXXXXXXX
Group C - 3
XXXXXXXXXX
etc.
I can't find an easy way to calculate the groupnumber.
I cannot use SUM distinctvalue for the grouping since the tabel is grouped
on two fields.
How can i get lastvalue for the textbox + 1.
Can somebody pleas help me out here!!
Thanks!!!
--
daniel_bTry doing a google search on "Reporting Services" and "Sleazy Hacks" -
I believe they cover this topic somewhat loosely in the "Green-band"
article.|||Thank you. That helped alot!!!
"papaboom" wrote:
> Try doing a google search on "Reporting Services" and "Sleazy Hacks" -
> I believe they cover this topic somewhat loosely in the "Green-band"
> article.
>|||You're welcome.
Monday, March 12, 2012
Group By, Max(date) query problem
Hello all:
I have an invoice header and detail tables and a customer table using sqlserver 2005. The Detail invoice table has price and product id. The header has the date and customerID.
I need to create a list of the most recent invoice date (and the product price) for each product for each customer. I can't use the group by because when I select both the max(date) and the price (as well as the productID and customerID which all have to be included in the group by) , I get more than one date per product per customer. I can only get the most recent date when I leave out the price and headerdetailID from the field selection.
Any help would be appreciated. Here is sample data & results.
invoiceHeadertable
invheaderID CustomerID InvoiceDate
1 40 1/1/2006
2 40 4/1/2006
3 80 3/1/2006
4 80 7/1/2006
5 80 8/12/2006
invoicedetailtable
invdetail ID invheaderID productcode price
11 1 AA 1.50
12 1 BB 1.30
13 1 CC 1.00
21 2 AA 1.40
23 2 CC 2.00
24 3 AA 2.00
25 3 CC 2.10
26 3 EE 1.10
27 4 AA 1.00
28 4 CC 2.00
29 4 EE 0.99
34 5 EE 1.55
CustomerTable
CustomerID Customername
40 johnCorp
80 maryCorp
Results
customer product most recent invoice(for this product) price
JohnCorp 40 AA 4/1/2006 1.40
JohnCorp 40 BB 1/1/2006 1.30
JohnCorp 40 CC 4/1/2006 2.00
maryCorp 80 AA 7/1/2006 1.40
maryCorp 80 CC 7 /1/2006 2.00
maryCorp 80 EE 8/12/2006 1.55
Something like this 'should' work for you. (Untested)
SELECT
dt.Customer,
dt.Product,
dt.InvoiceDate
d.Price
FROM InvoiceDetailTable d
JOIN ( SELECT
Customer,
Product,
InvoiceDate = max( InvoiceDate )
FROM InvoiceHeaderTable h
JOIN InvoiceDetailTable d
ON h.InvHeaderID = d.InvHeaderID
GROUP BY
Customer,
Product
) dt
ON ( d.Customer = dt.Customer
AND d.Product = dt.Product
AND d.InvoiceDate = dt.InvoiceDate
)
IF there was no more than one invoice per day for a customer, you could, in the derived table (dt), include in the SELECT list:
InvHeaderID = max( InvHeaderID )
And then JOIN ON InvHeaderID instead of the three fields I indicated.
Of course, if there were two invoices for the same customer in a day, that would still not be the correct solution.
|||Well, most of the time there would only be one invoice. But as is always the case, there can be an exception.
I had also wondered if the rank and partition function in sql server 2005 could apply, then one could just use a select query (if this is possible) to return the # 1 invoice per group but I have found no examples showing this used in a group by and where there are multiple tables involved.
Thanks
smhaig
|||select
ct.CustomerName as Customer,
ct.CustomerID as CustomerID,
idt.ProductCode as Product,
iht.InvoiceDate as MostRecentInvoiceDate,
idt.Price as Price
from InvoiceDetailTable as idt
join InvoiceHeaderTable as iht
on idt.invheaderID = iht.invheaderID
join CustomerTable as ct
on ct.CustomerID = iht.CustomerID
where not exists
(select 1
from InvoiceDetailTable as idtx
join InvoiceHeaderTable as ihtx
on idtx.InvHeaderID = ihtx.InvHeaderID
where idtx.ProductCode = idt.ProductCode
and ihtx.CustomerID = iht.CustomerID
and ihtx.InvoiceDate > iht.InvoiceDate)
order by
ct.CustomerName,
idt.ProductCode
|||-- Using SQL Server 2005
set nocount on
set dateformat mdy
create table invoiceHeadertable(invheaderID int,CustomerID int,InvoiceDate datetime)
insert into invoiceHeadertable(invheaderID ,CustomerID ,InvoiceDate )
select 1, 40, '1/1/2006' union all
select 2, 40, '4/1/2006' union all
select 3, 80, '3/1/2006' union all
select 4, 80, '7/1/2006' union all
select 5, 80, '8/12/2006'
create table invoicedetailtable(invdetailID int, invheaderID int, productcode char(2), price decimal(5,2))
insert into invoicedetailtable(invdetailID , invheaderID , productcode , price )
select 11, 1, 'AA', 1.50 union all
select 12, 1, 'BB', 1.30 union all
select 13, 1, 'CC', 1.00 union all
select 21, 2, 'AA', 1.40 union all
select 23, 2, 'CC', 2.00 union all
select 24, 3, 'AA', 2.00 union all
select 25, 3, 'CC', 2.10 union all
select 26, 3, 'EE', 1.10 union all
select 27, 4, 'AA', 1.00 union all
select 28, 4, 'CC', 2.00 union all
select 29, 4, 'EE', 0.99 union all
select 34, 5, 'EE', 1.55
create table CustomerTable(CustomerID int, Customername varchar(10))
insert into CustomerTable(CustomerID , Customername )
select 40, 'johnCorp' union all
select 80, 'maryCorp';
with cte(customer,product,[most recent invoice(for this product)],price,rn)
as (
select c.Customername,
d.productcode,
h.InvoiceDate,
d.price,
rank() over(partition by c.Customername,d.productcode order by h.InvoiceDate desc)
from CustomerTable c
inner join invoiceHeadertable h on h.CustomerID=c.CustomerID
inner join invoicedetailtable d on d.invheaderID=h.invheaderID
)
select customer,
product,
[most recent invoice(for this product)],
price
from CTE
where rn=1
order by customer,product
I want to thank Mark and Ron for their solutions and Arnie for getting me to think about two invoices on the same day for the same product and customer (which do exist actually).
I found these solutions to be on the level of advanced lessons for me to study. I have always had trouble with group by when I needed a unique ID on a table where I was selecting a max or min or first one, etc. on another field in the same table.
I have not found any good examples other than very basic ones for rank and partition so if anyone has a good site let me know. Meanwhile I will study what I have as I now have two great ways to solve my problem.
I did not give a duplicate item with my sample data so I will see how this sql 2005 query deals with this. I seem to remember something about ties and ranking and perhaps I could also use select distinct when I select the rank = 1.
The second standard sql query (Ron's) shows me both invoices when there are 2 on same date. It may be that this is the way the data should be displayed if the prices are different, so I will need to check further on that and see if I can tweak these 2 queries to deal with that.
Thank you all again
smHaig
|||And my thanks to Mark for demonstrating the more modern solution of the two!
Ron
Friday, February 24, 2012
Group and subreport
I have a report and I have defined a group in it.
both the group header and group footer has some information the detail section contain two subreports.
My requirement is that if there are more than 10 records in any of the subreport then only first 10 records will be displayed on each page along withh the group header and group footer. Somhow I managed to print the 10 records on each page with group header; but I am not able to get the footer on each page!!
Is there any option avaliable for this type of scenario.
I am using Crystal Report XI with ASP.NET.Hey.
Did u put a 'New Page After' in the group header or detail section of your main report?
If, then remove them there and place them in the Group Footer section.
Do not use any of the 'New Page Before/After' feathures in ure sub-reports.
Hope this helps.
Sunday, February 19, 2012
Group ..Alternate color ....Help Needed!
I'm using the following in the colorbackground of the group header
to change the color of the group when a group name changes.
=iif(RowNumber("DTM_Group1")Mod 2, "White", "Cornsilk")
But this is not working properly when the group name changes!
Could some one help me with this?groupname changes ? means ?
"c4raj" wrote:
> Hi,
> I'm using the following in the colorbackground of the group header
> to change the color of the group when a group name changes.
> =iif(RowNumber("DTM_Group1")Mod 2, "White", "Cornsilk")
> But this is not working properly when the group name changes!
>
> Could some one help me with this?
>|||I have created a Group by name DTM_Group1 in the table.
Whenever the value in the DTM_Group1 changes, I want the color should
be changed.
Just like alternate coloring the rows, I want the color to be changed
on the group.|||Try this instead:
=iif(RowNumber("DTM_Group1") Mod 2 = 0, "White", "Cornsilk")
"c4raj" wrote:
> Hi,
> I'm using the following in the colorbackground of the group header
> to change the color of the group when a group name changes.
> =iif(RowNumber("DTM_Group1")Mod 2, "White", "Cornsilk")
> But this is not working properly when the group name changes!
>
> Could some one help me with this?
>|||Try with RowNumber(Nothing) / ROwNumber()|||Tried... No luck!