Oracle Analytics Cloud and Server

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

OAS Date in DV manual query - Parameter / Filter

Accepted answer
369
Views
22
Comments
User_VMJII
User_VMJII Rank 4 - Community Specialist

I have manual query like:

select x, y, z, count(*) N

from table_a, table_b

where open_date <= '31.12.2020'

and nvl(close_date, '31.12.2020') >= '31.12.2020'

group by x, y, z

I need to upgrade it so that the user can choose any date in the visualization (instead of the specified '12/31/2020'). I have no idea how, please help me :)

Best Answer

  • [Deleted User]
    [Deleted User] Rank 7 - Analytics Coach
    Answer ✓

    Have you tried the very first recommendation already:

    Remove the WHERE clause from the data set. Create a Workbook on top of the data set and let users choose the dates they want themselves.

    DV is almost too feature-rich and self-service oriented in order to literally do what you want. For example any date-based DV native filter will automatically allow you both list and range selections:

    image.png image.png

    Meaning you will need to switch to something that does less thing automagically and where you have more finegrained control over. Like using the "Dashboard Prompt" viz type:

    image.png

    As you can see I have changed the "Filter Type" property of the visualization so that people are no longer allowed to use the date range option.

    image.png

    That date can then be set and used in a parameter:

    image.png

    And that parameter you can then use in your filter expression:

    image.png
«13

Answers

  • [Deleted User]
    [Deleted User] Rank 7 - Analytics Coach

    Where is your "manual query"? Are you doing a "Direct Database Query" in Answers? Are you using the SQL as a source for your DV data set? What exact product in which version are you using?

  • User_VMJII
    User_VMJII Rank 4 - Community Specialist
    edited Aug 16, 2024 12:16PM

    Sorry for the bad answer, I am not quite sure.

    I am using OAS DV, manual query in data, join diagram. About version - where can I find it?

    image.png
  • [Deleted User]
    [Deleted User] Rank 7 - Analytics Coach

    Top right. Click on your user's icon. Then choose "About".

  • User_VMJII
    User_VMJII Rank 4 - Community Specialist
  • [Deleted User]
    [Deleted User] Rank 7 - Analytics Coach

    Remove the WHERE clause from the data set. Create a Workbook on top of the data set and let users choose the dates they want themselves.

  • User_VMJII
    User_VMJII Rank 4 - Community Specialist

    But I don't have a "neutral" date in the table. I only have open date and close_date. It should create a "calendar" somehow, but I can't seem to join it with my data.

    And the parameter function in workbook offer me only current date. If there was a function where I could choose any date, it would be the easiest.

  • [Deleted User]
    [Deleted User] Rank 7 - Analytics Coach

    You can either deduce that notion of a "Year" according to your SQL definition already - it'll be presented as just another column.

    Or if you are worried about performance and storing your data isn't an issue then you can use data flows to store a data set in which you then create that notion of a year.

    It's very straightforward to have the year as part of your query. That's by far the easiest way.

  • User_VMJII
    User_VMJII Rank 4 - Community Specialist

    I'm sorry, but I don't understand your proposal (You can either deduce that notion of a "Year" according to your SQL definition already - it'll be presented as just another column.) very well.

  • [Deleted User]
    [Deleted User] Rank 7 - Analytics Coach

    If you have open date and close date in your DB, why don't you just deduce a "Year" column from it using SQL.

    Apparently this is what you call a year:

    where open_date <= '31.12.2020'
    and nvl(close_date, '31.12.2020') >= '31.12.2020'

    So why not put that as a column definition with CASE around it and the output being 2020. Then you have a new attribute which represents your year

  • [Deleted User]
    [Deleted User] Rank 7 - Analytics Coach

    @User_VMJII did you give up on this thread or did you do for one of the proposed alternatives?