Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Chart by months and week together Post Reply Post New Topic
Page  of 2 Next >>
Author Message
wibni
Newbie
Newbie


Joined: 16 Apr 2013
Online Status: Offline
Posts: 14
Quote wibni Replybullet Topic: Chart by months and week together
    Posted: 22 Jul 2013 at 12:10am
Hi, I'm using Crystal 2010.
Is it possible to have grouping on teh x-axis done by month and week?

On my report, I'm showing the rolling purchase order values for the last 12 months, but I would like to show the current months in weeks.

So if the report was run today the x axis would start with the PO total for October up to June and for July it shows every weeks PO total.
is that possible at all?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Jul 2013 at 3:55am
you could use a totext to convert it to a string and group on that.
The trick will be to make sure you make the string is in an alpha order that matches your date order.
IP IP Logged
wibni
Newbie
Newbie


Joined: 16 Apr 2013
Online Status: Offline
Posts: 14
Quote wibni Replybullet Posted: 22 Jul 2013 at 4:03am
Not sure I understand.

Currently my 'on change of' field is set to this formula: ToText(pwformatdate(ToNumber({POOpenOrders.CurrentDate})),"yyyy-MM")

This formula I can't use if I want to show it weekly.
But how do I show the first 11 months as month and only the current months as weeks?

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Jul 2013 at 4:21am

how are you defining the current months weeks? days 1-7 of the month as week 1? or by monday-sunday? or some other fashion?

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Jul 2013 at 4:33am
basically you just need to add an if statement to your formula but I do not know how you are defining your "week"...
 
 
if pwformatdate(ToNumber({POOpenOrders.CurrentDate})) in monthtodate then ToText(pwformatdate(ToNumber({POOpenOrders.CurrentDate})),"yyyy-MM") + week condition here else ToText(pwformatdate(ToNumber({POOpenOrders.CurrentDate})),"yyyy-MM")


Edited by DBlank - 22 Jul 2013 at 4:34am
IP IP Logged
wibni
Newbie
Newbie


Joined: 16 Apr 2013
Online Status: Offline
Posts: 14
Quote wibni Replybullet Posted: 22 Jul 2013 at 4:41am
So far I've only been able to create a table in the report with the info I require.
Getting a chart will be the tricky thing because ideally it should all be in the same series.

In the report table I define my weeks for the current months with 5 fields - one for each week in the month.
I look for the last day in the current month and find out the week number for that day.
Then I go backwards 5 weeks to get all weeks in that month.
Later in the report I sum up the individual fields and get the weekly total.
My database table contains the weeknumbers so I look for the highest week number of the year and use that as a reference (this is DB field {POOpenOrders.MaxWeekNo})


//field 1 = week 1
IF  ToText(pwformatdate(ToNumber({POOpenOrders.CurrentDate})),"yyyyMM") = ToText(DateAdd("m",0,currentdate),"yyyyMM")    
    AND DATEPART("ww",dateadd("m",1,currentdate-day(currentdate)) , crMonday) - 4 = {POOpenOrders.MaxWeekNo} //get weeknumber of 1st week of the month
THEN
    {POOpenOrders.ExtendedCost}
ELSE
    0

//field 2 = week 2
IF  ToText(pwformatdate(ToNumber({POOpenOrders.CurrentDate})),"yyyyMM") = ToText(DateAdd("m",0,currentdate),"yyyyMM")    
    AND DATEPART("ww",dateadd("m",1,currentdate-day(currentdate)) , crMonday) - 3 = {POOpenOrders.MaxWeekNo} //get weeknumber of 2nd week of the month
THEN
    {POOpenOrders.ExtendedCost}
ELSE
    0

//field 3 = week 3
IF  ToText(pwformatdate(ToNumber({POOpenOrders.CurrentDate})),"yyyyMM") = ToText(DateAdd("m",0,currentdate),"yyyyMM")    
    AND DATEPART("ww",dateadd("m",1,currentdate-day(currentdate)) , crMonday) - 2 = {POOpenOrders.MaxWeekNo} //get weeknumber of 3rd week of the month
THEN
    {POOpenOrders.ExtendedCost}
ELSE
    0

//field 4 = week 4
IF  ToText(pwformatdate(ToNumber({POOpenOrders.CurrentDate})),"yyyyMM") = ToText(DateAdd("m",0,currentdate),"yyyyMM")    
    AND DATEPART("ww",dateadd("m",1,currentdate-day(currentdate)) , crMonday) - 1 = {POOpenOrders.MaxWeekNo} //get weeknumber of 4th week of the month
THEN
    {POOpenOrders.ExtendedCost}
ELSE
    0

//field 5 = week 5
IF  ToText(pwformatdate(ToNumber({POOpenOrders.CurrentDate})),"yyyyMM") = ToText(DateAdd("m",0,currentdate),"yyyyMM")    
    AND DATEPART("ww",dateadd("m",1,currentdate-day(currentdate)) , crMonday)  = {POOpenOrders.MaxWeekNo} //get weeknumber of 5th week of the month
THEN
    {POOpenOrders.ExtendedCost}
ELSE
    0

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Jul 2013 at 5:15am
so I understand,
if a week (monday to sunday) straddles two months (current and last), you want to exlcude the counts from the the prior month and include them in the current month for that one week.
Is that correct?


Edited by DBlank - 22 Jul 2013 at 5:15am
IP IP Logged
wibni
Newbie
Newbie


Joined: 16 Apr 2013
Online Status: Offline
Posts: 14
Quote wibni Replybullet Posted: 22 Jul 2013 at 5:16am
yes.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Jul 2013 at 5:19am
are you using a stored proc or can you for your source?
IP IP Logged
wibni
Newbie
Newbie


Joined: 16 Apr 2013
Online Status: Offline
Posts: 14
Quote wibni Replybullet Posted: 22 Jul 2013 at 5:24am
Not using a stored procedure but can do.
Just using a view currently.
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.