Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

Determine and use data based on newest date

Received Response
21
Views
6
Comments

Summary

Determine and use data based on newest date

Content

I'm trying to create an RTF layout that only displays information from the latest set of responses from a User.  A user may have 1 or more attempts at completing an assessment, I want only the most recent responses displayed on the report.

I'm struggling with how to determine how to only select the latest responses from a User.  I've attached my data in the XML file and the current state of my RTF layout.

In my XML, Samuel Baxter has multiple responses over a few different dates.  I only want the responses from March 31st to show in the report. My dates are in canonical format already.

Any help is appreciated.

Answers

  • Sherry George
    Sherry George Rank 7 - Analytics & AI Coach

    The easiest option would be to have only the newest data available in the feed. What is the data model type?

  • Jim Poisson, PMP
    Jim Poisson, PMP Rank 3 - Community Apprentice

    This looks like it should work.  I'll give it a test and see.

    Thank you.

  • Sherry George
    Sherry George Rank 7 - Analytics & AI Coach

    Here is a bit of code and a general idea. Group XML by username and then by date. You then sort the  current group by date (descending) and set a variable as counter in the loop. We can use this variable to conditionally show the first record alone.

    <?for-each-group:entity;./users_username?>

    <?xdoxslt:set_variable($_XDOCTX,’vmaxdate’,0))?>

    <?sort:current-group()/users_first_name;'descending';data-type='text'?>

    Userid : <?users_username?>

    <?for-each-group:current-group();./instanceattempt_instanceattemptuserdatecompleted?>

    <?sort:current-group()/instanceattempt_instanceattemptuserdatecompleted;'descending';data-type='date'?>

    <?xdoxslt:set_variable($_XDOCTX,’vmaxdate’, xdoxslt:get_variable($_XDOCTX, ‘vmaxdate’) + 1)?>

    <?if:xdoxslt:get_variable($_XDOCTX,’vmaxdate’)=1?>

    <?users_first_name?> <?users_last_name?> <?instanceattempt_instanceattemptuserdatecompleted?> <? instanceprogress_instancescore?>

    <?end if?>

    <?end for-each?>

    <?end for-each?>

    If this was not you were looking for, please discard.

  • Jim Poisson, PMP
    Jim Poisson, PMP Rank 3 - Community Apprentice

    Unfortunately the data filtered to return the latest isn't an option in this case.

    I'm not sure what you mean by data model type, if you can clarify then I might be able to elaborate.

    In a nutshell, I have an application that returns a reporting results in a standard column and table report and I want to use the custom RTF to render the results differently based on certain client requirements.

  • Jim Poisson, PMP
    Jim Poisson, PMP Rank 3 - Community Apprentice

    I tried what you sent over and it seems to work when the data is not placed in a table.  When I place the code in a table the count (vmaxdate) doesn't seem to increment as expected.  I cannot figure out what I'm doing wrong.  I've attached a basic RTF file to use with XML in the original post.  All this simple RTF does is layout the same code in a table and without a table to show the vmaxdate counter not updating. 

    Any direction or pointers would be appreciated.

  • Sherry George
    Sherry George Rank 7 - Analytics & AI Coach

    Hi Jim,

    Just make sure where all the 'for-each' is starting and ending. I had in my previous reply shown you how they should be nested, follow the same order. MS word could make you believe they are in correct order but you can confirm using Field browser and click through 'Next' to find out.