<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Dynamically group records by date in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855973#M2485319</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I'm blind.  Now I see the "n".  I think the problem I'm having is that when CR populates the graph it is printing only the date of the DateAdd function instead of the full date and time value so if I have records that don't span more than one day they will all be grouped into one container when the chart is rendered.  I need to figure out how to get CR to print the whole date and time value instead of just the date in order to get the grouping right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all of your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 May 2010 14:46:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-05-19T14:46:51Z</dc:date>
    <item>
      <title>Dynamically group records by date</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaq-p/6855967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attempting to create a report that will dynamically group records into a set number of date buckets.  This is similar to grouping records by a date field and setting the days, weeks, months, etc property but instead of grouping by a set time span I want to a specific number of date groups regardless of date span.  So say i have records where the first date is today at 1am and the last record is today at 9 pm.  I want the data grouped into 10 groups and the time calculated for that group based on total time span / 10.  The first group would be 1AM to 3AM, the second would group 3AM to 5AM, etc..  The reason I am doing this is for a chart that displays record counts over time but the overall timespan will never be known until runtime.  Setting the chart for hourly or weekly doesn't work because if the user runs the report over a year the dates will be illegible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 16:31:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaq-p/6855967</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-18T16:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically group records by date</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855968#M2485314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well this SHOULD be easy. But leave it to CR make not...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can start by finding the minimum &amp;amp; maximum dates within your range:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Local DateTimeVar MinDate;
MinDate := Minimum({Table.DateField})
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Local DateTimeVar MaxDate;
MaxDate := Maximum({Person.ModifiedDate})
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then figure out what the the interval would be if the span is broken down into 10 equal parts"&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DateDiff("n", {@MinDate}, {@MaxDate}) / 10
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From there just use a formula to segregate each records into the appropriate groups:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
EvaluateAfter({@Interval});

IF {Table.DateField} &amp;gt;= {@MinDate} 
    AND {Table.DateField} &amp;lt;= DateAdd("n",{@Interval}, {@MinDate}) THEN 1 ELSE

IF {Table.DateField} &amp;gt; DateAdd("n",{@Interval}, {@MinDate})
    AND {Table.DateField} &amp;lt;= DateAdd("n",{@Interval} * 2, {@MinDate}) THEN 2 ELSE

IF {Table.DateField} &amp;gt; DateAdd("n",{@Interval} * 2, {@MinDate})
    AND {Table.DateField} &amp;lt;= DateAdd("n",{@Interval} * 3, {@MinDate}) THEN 3 ELSE

IF{Table.DateField} &amp;gt; DateAdd("n",{@Interval} * 3, {@MinDate})
    AND{Table.DateField} &amp;lt;= DateAdd("n",{@Interval} * 4, {@MinDate}) THEN 4 ELSE

IF {Table.DateField} &amp;gt; DateAdd("n",{@Interval} * 4, {@MinDate})
    AND {Table.DateField} &amp;lt;= DateAdd("n",{@Interval} * 5, {@MinDate}) THEN 5 ELSE

IF {Table.DateField} &amp;gt; DateAdd("n",{@Interval} * 5, {@MinDate})
    AND {Table.DateField} &amp;lt;= DateAdd("n",{@Interval} * 6, {@MinDate}) THEN 6 ELSE

IF {Table.DateField} &amp;gt; DateAdd("n",{@Interval} * 6, {@MinDate})
    AND {Table.DateField} &amp;lt;= DateAdd("n",{@Interval} * 7, {@MinDate}) THEN 7 ELSE

IF {Table.DateField} &amp;gt; DateAdd("n",{@Interval} * 7, {@MinDate})
    AND{Table.DateField} &amp;lt;= DateAdd("n",{@Interval} * 8, {@MinDate}) THEN 8 ELSE

IF {Table.DateField} &amp;gt; DateAdd("n",{@Interval} * 8, {@MinDate})
    AND {Table.DateField} &amp;lt;= DateAdd("n",{@Interval} * 9, {@MinDate}) THEN 9 ELSE

IF {Table.DateField} &amp;gt; DateAdd("n",{@Interval} * 9, {@MinDate})
    AND {Table.DateField}  &amp;lt;= {@MaxDate} THEN 10
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is where CR drops the ball... IMHO... it WON'T allow you to to group by a formula field that uses an aggregate in the formula (in this case Minimum &amp;amp; Maximum)... It will however allow to to graph on it, which I assume is what you are actually trying to do.  If anyone knows a way to work around the grouping issue, I'd love to know it myself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 19:29:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855968#M2485314</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-18T19:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically group records by date</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855969#M2485315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now that I think about it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use separate Begin Date &amp;amp; End Date parameters, you could do away with the MinDate &amp;amp; MaxDate formulas, using the parameters in their place. This would get rid of the aggregates in the formula...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 20:26:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855969#M2485315</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-18T20:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically group records by date</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855970#M2485316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is getting me much closer to my goal however when I implement it as described everything gets grouped into either group 1 or group 10.  I think the dateadd functions may be faltering.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 22:10:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855970#M2485316</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-18T22:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically group records by date</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855971#M2485317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK I've got it working with the following grouping formula:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;EvaluateAfter({@Interval});
 
IF {Log.NormalDateMin} &amp;gt;= {@MinDate} AND {Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval}, {@MinDate}) THEN {@MinDate} ELSE
 
IF {Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval}, {@MinDate}) AND {Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval} * 2, {@MinDate}) THEN DateAdd("n",{@Interval}, {@MinDate})ELSE
 
IF {Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval} * 2, {@MinDate}) AND {Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval} * 3, {@MinDate}) THEN DateAdd("n",{@Interval} * 2, {@MinDate}) ELSE
 
IF{Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval} * 3, {@MinDate}) AND{Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval} * 4, {@MinDate}) THEN DateAdd("n",{@Interval} * 3, {@MinDate}) ELSE
 
IF {Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval} * 4, {@MinDate}) AND {Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval} * 5, {@MinDate}) THEN DateAdd("n",{@Interval} * 4, {@MinDate}) ELSE
 
IF {Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval} * 5, {@MinDate}) AND {Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval} * 6, {@MinDate}) THEN DateAdd("n",{@Interval} * 5, {@MinDate}) ELSE
 
IF {Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval} * 6, {@MinDate}) AND {Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval} * 7, {@MinDate}) THEN DateAdd("n",{@Interval} * 6, {@MinDate}) ELSE
 
IF {Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval} * 7, {@MinDate}) AND{Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval} * 8, {@MinDate}) THEN DateAdd("n",{@Interval} * 7, {@MinDate}) ELSE
 
IF {Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval} * 8, {@MinDate}) AND {Log.NormalDateMin} &amp;lt;= DateAdd("n",{@Interval} * 9, {@MinDate}) THEN DateAdd("n",{@Interval} * 8, {@MinDate}) ELSE
 
IF {Log.NormalDateMin} &amp;gt; DateAdd("n",{@Interval} * 9, {@MinDate}) AND {Log.NormalDateMin}  &amp;lt;= {@MaxDate} THEN {@MaxDate}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only problem now is that it appears the resolution on this is limited to days.  If I have someone run the report for a single day I want it to display values at hour level grouping.  I'm guessing this has something to do with using the "n" for interval type.  I've done some looking and can't find any reference to "n" or it's use.  I know the other interval types and have tried them but I seem to have strange results.&lt;/P&gt;&lt;P&gt;Thanks for your help!  I'm much further along now than I was this morning!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 23:06:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855971#M2485317</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-18T23:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically group records by date</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855972#M2485318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"n" is minutes. &lt;/P&gt;&lt;P&gt;Here is the list of interval types from CR's online help for the DateDiff function:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
yyyy 	 Year 
q	 Quarter
m	 Month 
y	 Day of year 
d	 Day (both "y" and "d" find the difference in days) 
w	 Number of weeks between startDateTime and endDateTime 
ww	 Number of firstDayOfWeek's between startDateTime and endDateTime 
h	 Hour 
n	 Minute 
s	 Second
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It shouldn't be limited to days... The formula I posted... &lt;/P&gt;&lt;P&gt;I tested it against a range of date time values that span close to 9 years. &lt;/P&gt;&lt;P&gt;(the ModifiedDate from the Person.Contacts table of the sample Adventureworks database)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 13:28:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855972#M2485318</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T13:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically group records by date</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855973#M2485319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I'm blind.  Now I see the "n".  I think the problem I'm having is that when CR populates the graph it is printing only the date of the DateAdd function instead of the full date and time value so if I have records that don't span more than one day they will all be grouped into one container when the chart is rendered.  I need to figure out how to get CR to print the whole date and time value instead of just the date in order to get the grouping right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all of your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 14:46:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-group-records-by-date/qaa-p/6855973#M2485319</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T14:46:51Z</dc:date>
    </item>
  </channel>
</rss>

