Showing posts with label includes. Show all posts
Showing posts with label includes. Show all posts

Monday, March 26, 2012

Grouping data by x-axis labels

Hey guys,

I have thousands of records in the data source(i.e. Cube), which includes datetime information. I want to aggregate and present the data on a bar chart on monthly basis. That means the interval between the dates should be one month. Assume that the dates value will be labeled on the x-axis of the bar chart.

I tried to find out the solution for many days. I will really appreciate if anybody give me some idea.

Sincerely,

Amde

Try creating a category group with two expressions, using the following grouping expressions.

=Fields!DateField.Value.Year
=Fields!DateField.Value.Month

For the label you could use something like, =Fields!DateField.Value.ToShortDateString()

You could also use two category groups, if you wanted an inner set of labels for the month and another outer set for the year.|||

Hi,

Thank youy for your feedback, however that doesn't solve my problem: here is the thing;

I created a bar chart report. The x-axis value of this chart is a timestamp(datetime) field of a dimension. Thousands of records are inserted in to this field everyday, as a result, I will have the timestamp information every second or minute. So here is the thing, If for instance, I want to present last 5 months data in the bar chart(x-axis), the chart can not accomodate all the data and it doesn't look good to present a data which occured every minute or hours. So I want to present the data on monthly basis based on the StartDate and EndDate parameters value provided by the user.

Assume the user wants to preview 5 months record from 2006-03-04 to 2006-07-04, the data should be aggregated and presented on monthly basis as shown below, instead of directly displaying all the data as they appear in the dataset.


2006-03-04 2006-04-04 2006-05-04 2006-06-04 2006-07-04

Please let me know if you need more clarification.

Sincerely,

Amde

|||Adding the category fields with the groupings mentioned above should produce the grouping structure you are looking for. When you tried it what happened that was incorrect?

The bounds provided by the StartDate and EndDate parameters can either be used in the the sql query. Or, if it can't be done there, then you can set a filter for the category group. Also, the reason there is a group expression for Year is that the data may span multiple years and I'm assuming that you don't want the data for the same month in multiple years to be aggregated together.

Here is a sample report that uses the northwind database to show the number of orders placed for each month. It contains a bar chart and two parameters, which are used in the sql query.

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<IntegratedSecurity>true</IntegratedSecurity>
<ConnectString>Data Source=localhost; Initial Catalog=Northwind</ConnectString>
<DataProvider>SQL</DataProvider>
</ConnectionProperties>
<rd:DataSourceID>40232364-d6a5-4917-bcad-13308e3a8f62</rd:DataSourceID>
</DataSource>
</DataSources>
<BottomMargin>1in</BottomMargin>
<RightMargin>1in</RightMargin>
<ReportParameters>
<ReportParameter Name="StartDate">
<DataType>DateTime</DataType>
<DefaultValue>
<Values>
<Value>7/1/1996</Value>
</Values>
</DefaultValue>
<AllowBlank>true</AllowBlank>
<Prompt>Start Date</Prompt>
</ReportParameter>
<ReportParameter Name="EndDate">
<DataType>DateTime</DataType>
<DefaultValue>
<Values>
<Value>11/30/1996</Value>
</Values>
</DefaultValue>
<AllowBlank>true</AllowBlank>
<Prompt>End Date</Prompt>
</ReportParameter>
</ReportParameters>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:SnapToGrid>true</rd:SnapToGrid>
<Body>
<ReportItems>
<Chart Name="chart1">
<Legend>
<Visible>true</Visible>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Position>RightCenter</Position>
</Legend>
<Subtype>Plain</Subtype>
<Title />
<Height>5.125in</Height>
<CategoryAxis>
<Axis>
<Title />
<MajorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
</Axis>
</CategoryAxis>
<PointWidth>0</PointWidth>
<Left>0.375in</Left>
<ThreeDProperties>
<Rotation>30</Rotation>
<Inclination>30</Inclination>
<Shading>Simple</Shading>
<WallThickness>50</WallThickness>
</ThreeDProperties>
<DataSetName>Northwind</DataSetName>
<Top>0.125in</Top>
<PlotArea>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BackgroundColor>LightGrey</BackgroundColor>
</Style>
</PlotArea>
<ValueAxis>
<Axis>
<Title />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
<Scalar>true</Scalar>
</Axis>
</ValueAxis>
<Type>Bar</Type>
<Width>6.5in</Width>
<CategoryGroupings>
<CategoryGrouping>
<DynamicCategories>
<Grouping Name="chart1_CategoryGroup1">
<GroupExpressions>
<GroupExpression>=Fields!OrderDate.Value.Year</GroupExpression>
<GroupExpression>=Fields!OrderDate.Value.Month</GroupExpression>
</GroupExpressions>
</Grouping>
<Label>=MonthName(Fields!OrderDate.Value.Month)</Label>
</DynamicCategories>
</CategoryGrouping>
</CategoryGroupings>
<Palette>Default</Palette>
<ChartData>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Count(Fields!OrderID.Value)</Value>
</DataValue>
</DataValues>
<DataLabel />
<Marker>
<Size>6pt</Size>
</Marker>
</DataPoint>
</DataPoints>
</ChartSeries>
</ChartData>
<Style>
<BackgroundColor>White</BackgroundColor>
</Style>
</Chart>
</ReportItems>
<Height>5.75in</Height>
</Body>
<rd:ReportID>6323408e-15e1-4a7f-8151-ac96e7ebf862</rd:ReportID>
<LeftMargin>1in</LeftMargin>
<DataSets>
<DataSet Name="Northwind">
<Query>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
<CommandText>="SELECT OrderDate, OrderID FROM Orders WHERE Orders.OrderDate BETWEEN '" & Parameters!StartDate.Value & "' AND '" & Parameters!EndDate.Value & "'"</CommandText>
<DataSourceName>Northwind</DataSourceName>
</Query>
<Fields>
<Field Name="OrderDate">
<rd:TypeName>System.DateTime</rd:TypeName>
<DataField>OrderDate</DataField>
</Field>
<Field Name="OrderID">
<rd:TypeName>System.Int32</rd:TypeName>
<DataField>OrderID</DataField>
</Field>
</Fields>
</DataSet>
</DataSets>
<Width>9.375in</Width>
<InteractiveHeight>11in</InteractiveHeight>
<Language>en-US</Language>
<TopMargin>1in</TopMargin>
</Report>|||

Yes, that is correct. The assumption, group expression for year is also correct.

Thank you for your cooperation.

sql

Monday, March 19, 2012

Group Footer Overflow problem

Using Crystal Reports 7

Have a report that displays items and their amounts in the Details section

The report includes a Group section where in the Group Footer it displays the total amount of all the items from the Details section above.

We print on custom paper that lays out all the sections i.e Titles on the Page Header section, a box for the Details etc...

Problem arises when the Details section takes the entire page or most of it, leaving not enough room for the Group Footer section to print. Instead of generating a following page (i.e another page header etc) it dumps the footer on to the top of the next page - so we are left with the Group Footer (the totals) being displayed on our customs titles etc.

Therefore we end up with the subtotals being unreadable because they are printed on top of the titles of the custom page.

For some reason I can't get Crystal to regonise that this particular record flows on to another page.

I've tried using a variable to force a page break, but this either leaves big gaps in the report or some parts of the footer still overflow into the top on the next page.

Ideally I need to tell Crystal that the footer section should always print from this point on the page downwards (i.e. that start of the details section) - never above this point

I hope this is clear

Can anybody offer any other suggestions I could look into ??

CheersIn Crystal Reports 8.5, there's a property in Group Footers called PrintAtBottomOfPage. Maybe there's something similar in version 7?|||Yes Print at Bottom of Page is available in Crystal 7, however this would leave quite a significant bit of white space if say I had only a couple of detail lines.

Any other suggestions ?|||FYI

Seem to have come up with a solution that works so far:

Have created another Page Header section - so now have Page Header a and b
Page Header b is the same size as my Group Header section. Under Supress format for Page Header b have inserted:

pagenumber =1 or
InRepeatedGroupHeader = true;

Meaning that Page Header b will appear when there is no Group header section on subsequent pages

Sweet as!

Friday, March 9, 2012

GROUP BY question

Hi,
I have a table which includes date (day, month, year, as one col.) &
deposits for each day. I need to summarize the deposits into totals per
month. I have used SUM(deposit). I need to group it by month/year. How do I
do this? If I use DATENAME to create a col. to return a col. which includes
only the date & year, how can I use this to group the aggregate function? I
can��t use its alias in the group by clause & I can't group by the date in
its original format as this won't return monthly groupings. Is it possible to
do this without creating separate columns for each element of the date? Below
is the query:
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
SUM(deposit)
FROMloan_tbl
GROUP BY what? (I'd like to group by month - Year)
Any input would be greatly appreciated
thanks, Ant
Have the same expression in your GROUP BY as in the column list, or use a derived table, such as:
SELECT [mnth & yr], SUM(deposit)
FROM
(
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
deposit
FROM loan_tbl
) AS d
GROUP BY [mnth & yr]
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
> Hi,
> I have a table which includes date (day, month, year, as one col.) &
> deposits for each day. I need to summarize the deposits into totals per
> month. I have used SUM(deposit). I need to group it by month/year. How do I
> do this? If I use DATENAME to create a col. to return a col. which includes
> only the date & year, how can I use this to group the aggregate function? I
> can't use its alias in the group by clause & I can't group by the date in
> its original format as this won't return monthly groupings. Is it possible to
> do this without creating separate columns for each element of the date? Below
> is the query:
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> SUM(deposit)
> FROM loan_tbl
> GROUP BY what? (I'd like to group by month - Year)
> Any input would be greatly appreciated
> thanks, Ant
|||Ant
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
SUM(deposit)
FROM loan_tbl
GROUP BY DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date)
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
> Hi,
> I have a table which includes date (day, month, year, as one col.) &
> deposits for each day. I need to summarize the deposits into totals per
> month. I have used SUM(deposit). I need to group it by month/year. How do
I
> do this? If I use DATENAME to create a col. to return a col. which
includes
> only the date & year, how can I use this to group the aggregate function?
I
> cant use its alias in the group by clause & I can't group by the date in
> its original format as this won't return monthly groupings. Is it possible
to
> do this without creating separate columns for each element of the date?
Below
> is the query:
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> SUM(deposit)
> FROM loan_tbl
> GROUP BY what? (I'd like to group by month - Year)
> Any input would be greatly appreciated
> thanks, Ant
|||That's great. Thank you very much. Both solutions work nicely.
Regards
Ant
"Tibor Karaszi" wrote:

> Have the same expression in your GROUP BY as in the column list, or use a derived table, such as:
> SELECT [mnth & yr], SUM(deposit)
> FROM
> (
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> deposit
> FROM loan_tbl
> ) AS d
> GROUP BY [mnth & yr]
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Ant" <Ant@.discussions.microsoft.com> wrote in message
> news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
>
>

GROUP BY question

Hi,
I have a table which includes date (day, month, year, as one col.) &
deposits for each day. I need to summarize the deposits into totals per
month. I have used SUM(deposit). I need to group it by month/year. How do I
do this? If I use DATENAME to create a col. to return a col. which includes
only the date & year, how can I use this to group the aggregate function? I
can��t use its alias in the group by clause & I can't group by the date in
its original format as this won't return monthly groupings. Is it possible t
o
do this without creating separate columns for each element of the date? Belo
w
is the query:
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
SUM(deposit)
FROM loan_tbl
GROUP BY what? (I'd like to group by month - Year)
Any input would be greatly appreciated
thanks, AntHave the same expression in your GROUP BY as in the column list, or use a de
rived table, such as:
SELECT [mnth & yr], SUM(deposit)
FROM
(
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
deposit
FROM loan_tbl
) AS d
GROUP BY [mnth & yr]
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
> Hi,
> I have a table which includes date (day, month, year, as one col.) &
> deposits for each day. I need to summarize the deposits into totals per
> month. I have used SUM(deposit). I need to group it by month/year. How do
I
> do this? If I use DATENAME to create a col. to return a col. which include
s
> only the date & year, how can I use this to group the aggregate function?
I
> can't use its alias in the group by clause & I can't group by the date in
> its original format as this won't return monthly groupings. Is it possible
to
> do this without creating separate columns for each element of the date? Be
low
> is the query:
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> SUM(deposit)
> FROM loan_tbl
> GROUP BY what? (I'd like to group by month - Year)
> Any input would be greatly appreciated
> thanks, Ant|||Ant
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
SUM(deposit)
FROM loan_tbl
GROUP BY DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date)
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
> Hi,
> I have a table which includes date (day, month, year, as one col.) &
> deposits for each day. I need to summarize the deposits into totals per
> month. I have used SUM(deposit). I need to group it by month/year. How do
I
> do this? If I use DATENAME to create a col. to return a col. which
includes
> only the date & year, how can I use this to group the aggregate function?
I
> cant use its alias in the group by clause & I can't group by the date in
> its original format as this won't return monthly groupings. Is it possible
to
> do this without creating separate columns for each element of the date?
Below
> is the query:
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> SUM(deposit)
> FROM loan_tbl
> GROUP BY what? (I'd like to group by month - Year)
> Any input would be greatly appreciated
> thanks, Ant|||That's great. Thank you very much. Both solutions work nicely.
Regards
Ant
"Tibor Karaszi" wrote:

> Have the same expression in your GROUP BY as in the column list, or use a
derived table, such as:
> SELECT [mnth & yr], SUM(deposit)
> FROM
> (
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> deposit
> FROM loan_tbl
> ) AS d
> GROUP BY [mnth & yr]
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Ant" <Ant@.discussions.microsoft.com> wrote in message
> news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
>
>

GROUP BY question

Hi,
I have a table which includes date (day, month, year, as one col.) &
deposits for each day. I need to summarize the deposits into totals per
month. I have used SUM(deposit). I need to group it by month/year. How do I
do this? If I use DATENAME to create a col. to return a col. which includes
only the date & year, how can I use this to group the aggregate function? I
canâ't use its alias in the group by clause & I can't group by the date in
its original format as this won't return monthly groupings. Is it possible to
do this without creating separate columns for each element of the date? Below
is the query:
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
SUM(deposit)
FROM loan_tbl
GROUP BY what? (I'd like to group by month - Year)
Any input would be greatly appreciated
thanks, AntHave the same expression in your GROUP BY as in the column list, or use a derived table, such as:
SELECT [mnth & yr], SUM(deposit)
FROM
(
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
deposit
FROM loan_tbl
) AS d
GROUP BY [mnth & yr]
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
> Hi,
> I have a table which includes date (day, month, year, as one col.) &
> deposits for each day. I need to summarize the deposits into totals per
> month. I have used SUM(deposit). I need to group it by month/year. How do I
> do this? If I use DATENAME to create a col. to return a col. which includes
> only the date & year, how can I use this to group the aggregate function? I
> can't use its alias in the group by clause & I can't group by the date in
> its original format as this won't return monthly groupings. Is it possible to
> do this without creating separate columns for each element of the date? Below
> is the query:
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> SUM(deposit)
> FROM loan_tbl
> GROUP BY what? (I'd like to group by month - Year)
> Any input would be greatly appreciated
> thanks, Ant|||Ant
SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
SUM(deposit)
FROM loan_tbl
GROUP BY DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date)
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
> Hi,
> I have a table which includes date (day, month, year, as one col.) &
> deposits for each day. I need to summarize the deposits into totals per
> month. I have used SUM(deposit). I need to group it by month/year. How do
I
> do this? If I use DATENAME to create a col. to return a col. which
includes
> only the date & year, how can I use this to group the aggregate function?
I
> can?t use its alias in the group by clause & I can't group by the date in
> its original format as this won't return monthly groupings. Is it possible
to
> do this without creating separate columns for each element of the date?
Below
> is the query:
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> SUM(deposit)
> FROM loan_tbl
> GROUP BY what? (I'd like to group by month - Year)
> Any input would be greatly appreciated
> thanks, Ant|||That's great. Thank you very much. Both solutions work nicely.
Regards
Ant
"Tibor Karaszi" wrote:
> Have the same expression in your GROUP BY as in the column list, or use a derived table, such as:
> SELECT [mnth & yr], SUM(deposit)
> FROM
> (
> SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> deposit
> FROM loan_tbl
> ) AS d
> GROUP BY [mnth & yr]
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Ant" <Ant@.discussions.microsoft.com> wrote in message
> news:9D493D95-C622-4BB2-94DC-A389D823FF57@.microsoft.com...
> > Hi,
> > I have a table which includes date (day, month, year, as one col.) &
> > deposits for each day. I need to summarize the deposits into totals per
> > month. I have used SUM(deposit). I need to group it by month/year. How do I
> > do this? If I use DATENAME to create a col. to return a col. which includes
> > only the date & year, how can I use this to group the aggregate function? I
> > can't use its alias in the group by clause & I can't group by the date in
> > its original format as this won't return monthly groupings. Is it possible to
> > do this without creating separate columns for each element of the date? Below
> > is the query:
> >
> > SELECT DATENAME(MONTH,date)+ ' ' + DATENAME(YEAR,date) as [mnth & yr],
> > SUM(deposit)
> > FROM loan_tbl
> > GROUP BY what? (I'd like to group by month - Year)
> >
> > Any input would be greatly appreciated
> >
> > thanks, Ant
>
>