Solved

Crystal  formula or  Command Date Buckets

Posted on 2010-11-22
14
553 Views
Last Modified: 2012-06-27
trying to setup are report using some date fields to create some date buckets

So I have a start date and a end date as fields.

I want to create a command or use formulas(prefer) to calculate the dates between those start and end dates.

bucket 1is   enddate - startdate = time duration1  x .025,  then add this to  startdate

bucket 2 is enddate - startdate = time duration2  x .063 , then add this to startdate

bucket 3 is  enddate - startdate = time duration3  x .0125 , then add this to startdate

All Dates are actual numbers and I end up converting them over to dates to view them


Anyone have suggestion on how to do this?
0
Comment
Question by:shockacon
  • 6
  • 6
  • 2
14 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 34194123
I am not clear what you are trying to do.

You can use DateDiff to subtract dates with you choice of days, weeks, hours, etc
You can then use DatsAdd to add the units back

mlmcc
0
 

Author Comment

by:shockacon
ID: 34268139
OK so I did this and it works!! :)

Anyway i now believe i need to put it all into one formula, as Im trying to get this into a crosstab scenario..

this is what I want to do.. is it possible in one formula to have multiple "buckets" or results? Im getting a "Boolean is required" or" ) is missing"  etc. errors..


if ((ESPs_ARSToLocalDate ({@lts - ops}* .025) + {projectdesc.opsStart}))
then 'milestone1'

else if ((ESPs_ARSToLocalDate (({@lts - ops}* .088) + {projectdesc.opsStart})

then 'milestone2'
else  '0'
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34268263
The value of the test must be true or false

((ESPs_ARSToLocalDate ({@lts - ops}* .025) + {projectdesc.opsStart}))
This results in a number

The second if is missing some )

II am still not clear what you are trying to do.
Can you give an example with data as to what goes in which bucket?
Yes, you can use a formula like you are trying to produce.

mlmcc
0
 

Author Comment

by:shockacon
ID: 34268686
im trying to create buckets of time for projects its the  differences between a start date and end date of each project..  
the dates are a unix time stamp or something and im trying to increment up from beginning.. .025 .088. .095 etc etc


I have 9 buckets that each have the increment and they work. My thought was to put it into one formula as the end result is to put it into a crosstab , otherwise it would be "stacked" 9 times over and I wouldnt get the result I need, so again, I wanted to put it in one formula so i could crosstab it out.

make sense?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34268957
Something like

If enddate - startdate = time duration1  x .025 then
    "bucket 1"
else if enddate - startdate = time duration2  x .063  then
    "bucket 2"
else ETC

mlmcc
0
 

Author Comment

by:shockacon
ID: 34269027
yes thats what i did.. and where im stuck.. its telling me "a boolean is required" on bucket 2 portion
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34269162
Can you paste the formula

mlmcc
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:shockacon
ID: 34269166
if ESPs_ARSToLocalDate (({@lts - ops}* 1.002) + {projectdesc.opsStart})
then 'milestone1'



else if ESPs_ARSToLocalDate (({@lts - ops}* 1.003) + {projectdesc.opsStart})
then 'milestone2'
else  '0'
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34269871
You have to compare the calculated field to something.  Look at my formula.

mlmcc
0
 

Author Comment

by:shockacon
ID: 34270148
I did and dont see the difference??
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34271054
Yours

if ESPs_ARSToLocalDate (({@lts - ops}* 1.002) + {projectdesc.opsStart})
then 'milestone1'

Mine
If enddate - startdate = time duration1  x .025 then
    "bucket 1"

Mine has the = to compare enddate - startdate to the time duration
Yours simply adds 2 numbers but doesn't compare it to anything

mlmcc
0
 
LVL 34

Expert Comment

by:James0628
ID: 34272461
 I'm guessing that ESPs_ARSToLocalDate converts the calculated value to a date, so what you're ending up with is something like:

if #12/01/2010#
then 'milestone1'
else if #12/02/2010#
then 'milestone2'
else  '0'


 You have to do some kind of test on those dates (compare them with another date or check the month or something).  Just saying "if date" makes no sense to CR.  That's what mlmcc was getting at.

 James
0
 

Author Comment

by:shockacon
ID: 34294310
hmm.. maybe this cant be done then. not sure what dates I would be comparing it too.. (itself maybe?)

the ultimate goal is to get them in a pivot table thats why I was working to put them in one formula.
0
 
LVL 34

Accepted Solution

by:
James0628 earned 500 total points
ID: 34299021
Maybe you can't.

 Looking back at your original and follow-up posts, you've said that you're trying to use start date and end date fields to define "buckets" and that you're trying to create a cross-tab.  So, presumably you want to use the difference between the dates in some way to define the columns or rows in a cross-tab.  In general, you could do that, in various ways.

 However, it looks like you're trying to create multiple "buckets" for each record.  You can't do that.  CR can only include each record in one group.  Going back to your original post:

bucket 1is   enddate - startdate = time duration1  x .025,  then add this to  startdate

bucket 2 is enddate - startdate = time duration2  x .063 , then add this to startdate

bucket 3 is  enddate - startdate = time duration3  x .0125 , then add this to startdate


 You have nothing there that says "use the first formula for these records, the second formula for those records, etc.".  Those formulas would return 3 separate values for each record, like you're trying to include each record in all 3 "buckets", which you can't do.

 If you're not actually trying to include each record in multiple "buckets", can you try again to explain exactly what you're trying to do?

 FWIW, going back to mlmcc's suggestion, he was assuming that "time duration1", "time duration2" and "time duration3" were fields or formulas in your report, so, for example, (enddate - startdate = time duration1 x .025) would be testing to see if (enddate - startdate) was equal to (time duration1 x .025).  In that case, you could have one formula that produced different values depending on whether (enddate - startdate) was equal to (time duration1 x .025), or (time duration2  x .063), or (time duration3  x .0125).  You could use that formula for the columns or rows in a cross-tab.

 However, I'm assuming that "time durationX" was referring to the result of (enddate - startdate), so (enddate - startdate = time duration1 x .025) really meant ((enddate - startdate) x .025).  In that case, you've got different 3 different formulas producing different values for the same record.

 James
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now