Wrox Programmer Forums
|
BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7
This is the forum to discuss the Wrox book Professional SQL ServerReporting Services by Paul Turley, Todd Bryant, James Counihan, George McKee, Dave DuVarney; ISBN: 9780764568787
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2005, 06:26 PM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default calculate 2 textboxes

I'm not sure if anyone had try to calculate two textboxes in the detail section of the table, but this seems nearly impossible. It seems something so simple, but yet i can't figure out how.

For example I have a field in textbox1 and another in textbox2 in my table. All I want to do is ReportItems!textbox1.value + ReportItems!textbox2.value in textbox3 and get my result, but it only allows me to do this in header or footer. I know this can be done as easily in my SQL query, but it just annoys me not being able to do this.

Anyone got any ideas or know if RS 2005 will suppor this?

 
Old December 1st, 2005, 06:31 PM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To clarify I can caculate it within same grouping but can't if in different grouping. For example Textbox1 is the detail for a dataset1 and textbox2 is another detail of another dataset, textbox3 where I want the result of both textbox1 and textbox2 to go to.

 
Old December 1st, 2005, 09:11 PM
Wrox Author
 
Join Date: May 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've never had a problem with this. This capability is the same in SSRS 2000 and 2005. Here's an example... (create a new report, view code and replace all with the following):

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  <RightMargin>1in</RightMargin>
  <Body>
    <ReportItems>
      <Table Name="table1">
        <Height>0.75in</Height>
        <Style />
        <Header>
          <TableRows>
            <TableRow>
              <Height>0.25in</Height>
              <TableCells>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox1">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>11</ZIndex>
                      <rd:DefaultName>textbox1</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value>Product Name</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox2">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <TextAlign>Right</TextAlign>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>10</ZIndex>
                      <rd:DefaultName>textbox2</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value>Unit Price</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox3">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <TextAlign>Right</TextAlign>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>9</ZIndex>
                      <rd:DefaultName>textbox3</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value>Quantity</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox4">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <TextAlign>Right</TextAlign>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>8</ZIndex>
                      <rd:DefaultName>textbox4</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value>Calculated Total</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
              </TableCells>
            </TableRow>
          </TableRows>
        </Header>
        <Details>
          <TableRows>
            <TableRow>
              <Height>0.25in</Height>
              <TableCells>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="productname">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>3</ZIndex>
                      <rd:DefaultName>productname</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value>=Fields!productname.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="unitprice">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <TextAlign>Right</TextAlign>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>2</ZIndex>
                      <rd:DefaultName>unitprice</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value>=Fields!unitprice.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="quantity">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <TextAlign>Right</TextAlign>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>1</ZIndex>
                      <rd:DefaultName>quantity</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value>=Fields!quantity.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox5">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <TextAlign>Right</TextAlign>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <rd:DefaultName>textbox5</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value>=ReportItems!unitprice.value * ReportItems!quantity.value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
              </TableCells>
            </TableRow>
          </TableRows>
        </Details>
        <DataSetName>Northwind</DataSetName>
        <Top>0.375in</Top>
        <Footer>
          <TableRows>
            <TableRow>
              <Height>0.25in</Height>
              <TableCells>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox7">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>7</ZIndex>
                      <rd:DefaultName>textbox7</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox8">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>6</ZIndex>
                      <rd:DefaultName>textbox8</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox9">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>5</ZIndex>
                      <rd:DefaultName>textbox9</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox6">
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingRight>2pt</PaddingRight>
                      </Style>
                      <ZIndex>4</ZIndex>
                      <rd:DefaultName>textbox6</rd:DefaultName>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
              </TableCells>
            </TableRow>
          </TableRows>
        </Footer>
        <TableColumns>
          <TableColumn>
            <Width>2.16667in</Width>
          </TableColumn>
          <TableColumn>
            <Width>2.16667in</Width>
          </TableColumn>
          <TableColumn>
            <Width>2.16667in</Width>
          </TableColumn>
          <TableColumn>
            <Width>2.16667in</Width>
          </TableColumn>
        </TableColumns>
      </Table>
    </ReportItems>
    <Style />
    <Height>2in</Height>
  </Body>
  <TopMargin>1in</TopMargin>
  <DataSources>
    <DataSource Name="Northwind">
      <rd:DataSourceID>868e8ea4-11be-42d1-8833-681aca87e3b1</rd:DataSourceID>
      <ConnectionProperties>
        <DataProvider>SQL</DataProvider>
        <ConnectString>data source=localhost;initial catalog=Northwind</ConnectString>
        <IntegratedSecurity>true</IntegratedSecurity>
      </ConnectionProperties>
    </DataSource>
  </DataSources>
  <Width>8.66667in</Width>
  <DataSets>
    <DataSet Name="Northwind">
      <Fields>
        <Field Name="productname">
          <DataField>productname</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="unitprice">
          <DataField>unitprice</DataField>
          <rd:TypeName>System.Decimal</rd:TypeName>
        </Field>
        <Field Name="quantity">
          <DataField>quantity</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
      <Query>
        <DataSourceName>Northwind</DataSourceName>
        <CommandText>select p.productname, od.unitprice, od.quantity from [order details] od inner join products p on od.productid = p.productid</CommandText>
        <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
      </Query>
    </DataSet>
  </DataSets>
  <LeftMargin>1in</LeftMargin>
  <rd:SnapToGrid>true</rd:SnapToGrid>
  <rd:DrawGrid>true</rd:DrawGrid>
  <rd:ReportID>4dda95b6-19b5-42dd-bb4e-aadd9e9fff43</rd:ReportID>
  <BottomMargin>1in</BottomMargin>
  <Language>en-US</Language>
</Report>


Paul Turley, MCSD, MCDBA, MCT, MSF Practitioner





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to calculate bandwidth debuajm C# 2005 0 January 16th, 2007 07:40 AM
Calculate ivangr Visual Basic 2005 Basics 0 April 9th, 2006 04:39 AM
Two TextBoxes hunzian78@yahoo.com ASP.NET 1.0 and 1.1 Basics 5 April 1st, 2006 06:32 AM
calculate the values up crmpicco Classic ASP Basics 3 February 1st, 2005 10:18 AM
Help me How to calculate minhtri VB How-To 4 June 8th, 2004 04:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.