This is a migrated thread and some comments may be shown as answers.

MAX(DateField) returns last row in group, not the max

8 Answers 178 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 09 Jan 2012, 10:03 PM
Version:  5.3.11.1116

On several reports, in group/report summary lines, I need to return the maximum date for the group.  What is returned instead by =Max(Fields.LastTranDate) is simply the LastTranDate value of the group. 

Data type of LastTranDate in database/entity framework:  datetimeoffset: 

How do I actually get the maximum date value rather than the value of the maximum row? 

8 Answers, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 12 Jan 2012, 04:42 PM
Hi Rick,

We were unable to reproduce the problem on our end. What you can do is to send us a runnable sample project in order to help us exhibit the problem at our side. Additionally you can create your own user function - for more information you can check our Crosstab demo and our User Functions KB article.

Regards,
IvanY
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Balen
Top achievements
Rank 1
answered on 22 Oct 2019, 10:29 AM

HI Guys, 

I have this issue too. I know this is feed is pretty old but i have not been able to find the solution anywhere. so wondered if any one had any luck.

0
Neli
Telerik team
answered on 25 Oct 2019, 07:18 AM

Hello Balen,

If you want to display the MAX date for a specific group, one of the ways is by the Exec function which accepts two arguments:

- the data scope - in this case, it will be the group

- the expression - "= Max(Fields.Date)"

So, eventually, the expression that will display the MAX date for each group will be:

= Exec("group", Max(Fields.Date))

Another option is if you have report groups. In this case, you can display the MAX date in the group footer section. Then you don't need to specify the scope, so the Expression will be:

= Max(Fields.Date)

This is demonstrated in the attached report.

 

Regards,
Neli
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Balen
Top achievements
Rank 1
answered on 29 Oct 2019, 04:14 PM

Hi Neil,

Thank you for your recommendation.

In my situation i want to make a report as follows.

I am trying to create a report where agents have logged on to different campaigns through out the day. so i want to know the first time they logged in and the last time they logged out of any of the campaigns they have worked on through out the day. I have used the later of the recommendation however this seems to only get the last logged out of the campaign they first logged into.

Version: 10.2.16.1025

0
Neli
Telerik team
answered on 01 Nov 2019, 03:00 PM

Hi Balen,

It is strange that after applying the solution, the report does not work as expected. Which field do you use for the grouping? Make sure the Aggregate function is in the scope of the grouping section. I suggest to send us screenshots of the report, so we can try to reproduce the behavior.

I am also attaching the previous report in version  10.2.16.1025.

 

Regards,
Neli
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Balen
Top achievements
Rank 1
answered on 01 Nov 2019, 04:26 PM

Hi Neil,

Attached is screenshots of the details.

So the 2 columns that are in the database and the stats that are being pulled into telerik. 

This 2 telerik snippets are from reports made in telerik. 

The first is when i used functions FIRST and MAX but we can see that the MAX function is not getting the correct value.

The second is using MIN and MAX functions, from this we can see that neither of the stats are correct.

I am using oData V4 to get data from postgres to telerik.

0
Nasko
Telerik team
answered on 06 Nov 2019, 11:08 AM

Hello Balen,

The only possible options for the MIN and MAX functions to not work as expected are:

  • The compared data fields are of a string data type and the functions return unexpected results;
  • The comparison is executed in a different data scope and cannot compare all of the data;
  • When working with DateTime types the comparison takes into account only the Date part of the value;

It is not technically possible to understand which of the above are in effect in your scenario, unless you provide us a sample report with dummy data demonstrating the issue, or modify the report which was provided in previous replies, so it replicates the problem.

Regards,
Nasko
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Balen
Top achievements
Rank 1
answered on 05 Dec 2019, 04:50 PM

Thank you, couldnt get it to work in the trdx so sorted in the data source.

Thank you for your assistence

Tags
General Discussions
Asked by
Rick
Top achievements
Rank 1
Answers by
IvanY
Telerik team
Balen
Top achievements
Rank 1
Neli
Telerik team
Nasko
Telerik team
Share this question
or