Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

fetching last 60 days data with reference to current system date from oracle database to power bi

Hi everyone, 

Can somebody please tell me, how to fetch last 60 days data with reference to current system date from oracle database to power bi desktop.
I tried changing the SQL script in the get data option, but getting this error ("The keys didn't match any rows in the table").

SQL SCRIPT : 
SELECT * FROM TABLENAME
WHERE COLUMN_NAME >= TRUNC(sysdate)-60


Hope to hear from you soon.

Thanks !

 
  • Have you tried filtering your table from the Query Editor instead of directly through SQL? 

    Filter the date colum to any date and then in the formula bar replace the filter condition similar to below:

     

    Table.SelectRows(#"Removed Columns", each ([Transaction Date] = #date(2018, 1, 1)))


    Table.SelectRows(#"Removed Columns", each ([Transaction Date] >=Date.AddDays(Date.From(DateTime.LocalNow()),-60)))

     

     

  • hi  Anonymous 

    I would suggest you filter it in edit queries as below:

    Step1:

    Get all data without "where" conditional in code.

    SELECT * FROM TABLE_NAME

    Step2:

    In edit queries, add a custom column as below

    Duration.Days (DateTime.Date(DateTime.LocalNow()) - [COLUMN_NAME] )

     

    Step3:

    Filter this custom column that is less than 194

    Result:

    and you could remove this custom column.

     

    here is my sample file, please try it.

     

    Regards,

    Lin

6 Replies