Cognos Analytics

 View Only
  • 1.  How to retrieve Random Sample of data in Cognos

    Posted Thu July 22, 2021 05:03 PM
    Hi all, I'm sure this is not the first time someone has posed this question, so here is my challenge:

    I was able to use the Random function to get a specific number of Random values. All was good, except, this applies to the entire data set. What the customer wants is to get the specific random samples by branch. I have tried to apply the 'FOR' clause and got an error. I have tried to 'Group by' , I even tried Page Breaks, and it doesn't give the sample size by Branch.

    Here is an example of my statement that works: rank([Random Number]) < 10

    Again, this works fine for the entire set of data, but I need to return 9 random samples for EACH branch.

    This does not work; rank([Random Number] for [Branch])

    Any suggestions?

    ------------------------------
    Stephune Waites
    ------------------------------

    #CognosAnalyticswithWatson


  • 2.  RE: How to retrieve Random Sample of data in Cognos

    Posted Fri July 23, 2021 01:06 PM

    Hi Stephune,
    I tried the following with the gosales samples database and it works fine. 
    On a report I added the detail filter:
    rank (random() for [Order Number] ) < 4
    [Order Number] is a data item defined as: [C].[C_gosales_8_2_src].[ORDER_DETAILS].[ORDER_NUMBER]

    Attached is the complete report and a screenshot of the output.

    // Henk



    ------------------------------
    Kind regards,
    HENK CAZEMIER
    ------------------------------

    Attachment(s)

    xml
    Rand per group.xml   6 KB 1 version


  • 3.  RE: How to retrieve Random Sample of data in Cognos

    Posted Mon July 26, 2021 04:13 PM
    Hello Henk,

    Thank you for the suggestion and it works. I had to do some additional steps, but in the end it was successful.

    Thank very much my friend.

    ------------------------------
    Stephune Waites
    ------------------------------