Showing posts with label footer. Show all posts
Showing posts with label footer. Show all posts

Monday, March 26, 2012

Formatting totals with the table footer

Here's a scenario that i'm trying to figure out.

In the table details, i return order number, item, manufacturer, and total cost of the order.

This is what it originally looked like:

Order Number Item Manufacturer Total Order Cost

1 portable DVD Company A $100

1 portable DVD Company B $100

1 portable DVD Company C $100

2 portable DVD Company B $100

2 portable DVD Company D $100

2 portable DVD Company F $100

Grand Total $600

I can get the table to look like this after hiding duplicates:

Order Number Item Manufacturer Total Order Cost

1 portable DVD Company A $100

1 portable DVD Company B $100

1 portable DVD Company C $100

2 portable DVD Company B $100

2 portable DVD Company D $100

2 portable DVD Company F $100

Grand Total $600

The problem is the grand total. It should be $200 but it takes in the all total costs in the row because I have:

=FormatCurrency(Sum(Fields!TotalCost.Value)) in the footer and it'll sum up all.

I'm stumped here. Any suggestions are greatly appreciated.

Thanks a lot for taking the time to read.

Hiding duplicates will invariably give you wrong values especially when adding. I have had the same scenario and I found the answer here on this fourm long time back. You need to do a sum of TotalOrderCost for distinct values of OrderNumber. In the Code block (available from the Report Properties dialog), you would add:

Dim orderIDs As System.Collections.Hashtable
Dim total As Double

Function MyFunc(ByVal orderID As Object, ByVal TotalOrderCost As Obect) As Double
If (orderIDs Is Nothing) Then
orderIDs = New System.Collections.Hashtable
End If
If (orderID Is Nothing) Then
MyFunc = total
Else
If (Not orderIDs.Contains(orderID)) Then
total = total + TotalOrderCost
orderIDs.Add(orderID, TotalOrderCost)
End If
MyFunc = total
End If
End Function

3.) In your report, you add a hidden textbox with the value expression to compute the value:

=Sum(Code.MyFunc(Fields!OrderID.Value, Fields!TotalOrderCost.Value))

4.)In the footer of the table, you add a textbox with the value expression:

=Code.MyFunc(Nothing, Fields!TotalOrderCost.Value)

to return the total value.

Hope this helps....

|||

Thanks for your help.

I'll give it a try.

Friday, March 23, 2012

Formatting text in a single table cell

I have a two column report. However, in the footer, i'd like to present a
column similar too:
Total spent: $100
Total left: $1,230
So that the NUMBER values on the right are completely right justified, but
the text on the left is actually LEFT justified. Can this type of
formatting occurr within the same cell?
TIA,
--
Brian Grant
Senior Programmer
SI International
www.si-intl.comJustification is done on a per cell basis. What you can do is use a
rectangle that contains two textboxes for each row. This would allow you to
apply the justification as needed.
--
Bruce Johnson [MSFT]
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"G" <brian.grant@.si-intl-kc.com> wrote in message
news:%23Kh2U%237fEHA.3476@.tk2msftngp13.phx.gbl...
> I have a two column report. However, in the footer, i'd like to present a
> column similar too:
> Total spent: $100
> Total left: $1,230
> So that the NUMBER values on the right are completely right justified, but
> the text on the left is actually LEFT justified. Can this type of
> formatting occurr within the same cell?
> TIA,
> --
> Brian Grant
> Senior Programmer
> SI International
> www.si-intl.com
>

Friday, February 24, 2012

format date from 2/25/2006 to 02/25/2006

in footer of my report i show a current date by this

=Format(Today(), "d")

as a result i gave those

3/21/2007

but wont date like this 03/21/2007

How ?

Use this expression:

Format(Today,"MM/dd/yyyy")

Can you please mark my post as answer after that?