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
tarun912
Helper IV
Helper IV

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 !

 
2 ACCEPTED SOLUTIONS

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)))

 

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

hi  @tarun912 

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] )

 

6.JPG

Step3:

Filter this custom column that is less than 194

8.JPG

Result:

9.JPG

and you could remove this custom column.

 

here is my sample file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

If you have date table. you can get easily like

Rolling last 60 days = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],today(),-60,Day))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

Hi Amit, 

Thanks for providing me with the query.
I understand that query, but my issue is :
- I have uploaded entire dataset from oracle database, but when I am publishing my report to the power bi service and then schedule refresh the dataset there , it is giving me a timeout error because schedule refresh in power bi doesn't support of dataset load time of more than 2 hrs and in my case dataset is taking around 5.5 hrs in loading (I noted this time when I refreshed the dataset in power bi desktop) 

So, I just want to pull only 200 days back data via Get data option so that I will have less data in power bi desktop (only the required dataset) and therefore power bi service refresh will work successfully.

And if you know any other way of getting this thing then please let me know.
I think now you will got my point. 
Hope to hear from you soon.
Thanks !

While creating a connection , you have the option of advance, then you can write a query in that, do this for the transaction table.

 

AdvanceProperty.png

ya sure, I did that 
I used this SQL script :
SELECT * FROM TABLE_NAME
WHERE COLUMN_NAME >= TRUNC(sysdate)-194


but getting the following error "THE KEY DIDN'T MATCH ANY ROWS IN THE TABLE".Capture 3.PNG

hi  @tarun912 

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] )

 

6.JPG

Step3:

Filter this custom column that is less than 194

8.JPG

Result:

9.JPG

and you could remove this custom column.

 

here is my sample file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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)))

 

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.