Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Use a date query in parameters

Is it possible to create an Oracle SQL query in parameters that would be "last 12 months"?

I'm pulling in multiple tables with an Oracle query that would look like:

let
   query = "SELECT * FROM TABLE WHERE DATE_COLUMN >= TO_DATE('" & RangeStart & "', 'DD/MM/YY')",
   Source = Oracle.Database("abcd.com", [HierarchicalNavigation=true, Query=query])
in
    Source

I created the parameter that currently has "1/4/22" for April 1, 2022.

dpibarker_0-1682884808262.png

Is it possible to create a parameter that dynamically changes to  "last 12 months"?

I know, I could just have my SQL query be something like this:

WHERE
    DATE_COLUMN BETWEEN TRUNC(ADD_MONTHS(SYSDATE,
    -12),
    'MONTH')
    AND TRUNC(SYSDATE,
    'MONTH') -1

 but I have multiple tables and I don't want to have to go into each query and manually update the date range.

1 REPLY 1
ppm1
Solution Sage
Solution Sage

Do you need to use hand-authored queries? Why not just connect to your source and use the power query experience to filter your data with the date filter options (that include a relative option). It should "fold" back to your source with similar queries.

 

ppm1_0-1682892672431.png

 

 

Pat

Microsoft Employee

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.