I need to return 3 pieces of data:
1 - Case No
2 - Date Time
3 - User ID
Several user will access a case but I need to return only the last user on each case. While I can write custom SQL and do a max on the date field because there are many users I will still receive more than one record. While this does not have to happen at the report level it is the preferred option.
Is your max only on date or date time ( ie some form of time stamp) ?
I would have though the chances of two users have the same date time on a case would be almost imposssible given time stamp normally goes down to seconds even milliseconds.
Have your query as Max(Date) AS YourDate, User and Case
Then in your report have a Section on Case.
You then have Case, YourDate and User inside your section. Also a ‘hidden’ column =Max(Date IN Section).
The row where YourDate = Max(Date in Section) is the one you want to show.
Create a variable dimension (MyFilter) that says If(YourDate = Max(Date in Section);1;0)
Now you can create a block filter to only show rows where MyFilter=1.
It will work for some of these sort of queries.
I use this technique when I have to display a summary page (for example one User per Case) and also a detail page (all transactions) in the same report - but don’t want to run two queries.
This option that you provided will not work for my purposes. I need to have a single block containing a single recors for each case having the max date for that case.
BOCP,
I am pulling data from an outside system. The currnet user function that you mentioned is not an atribute in that system. The currentuser function is a BO function that tells you who is working on a document in BO.
Now because I am pulling these 3 different fields the max date per case number will not work because I get a distinct record for each user that touched the case. I need to only get the final record that will include the case number, the user id, and the tinestamp.
What I am looking fo ris the last user that touched each case. In the example that I provided the report should only return the last user for case 1. This would he user3.
No problem, great for asking questions such as first Order, Last Order e.t.c.
If you use a sequence number in your fact table then you can use this technique to get first record, second record, last record…etc, by defining a series of filters and step through all the history, by a given dimension.
Easy to understand from a users perspective also…:).
Found an easy way of doing this. I create 2 queries.
The first query contained the case # and the Max(datestamp).
The second query contained the case #, datestamp and the userid.
I merged these two queries in the report and then used the Case# and Max(datestamp) from query 1 and added the UserID from query 2. While this may not be the best way it if functional.
To everyone that chimed in, Thank you for the assistance,