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
karun_r
Employee
Employee

Filter based on date in R script

I have a dataframe which holds a column with date values. The datatype for this column is date in Power BI. When I try to modify this dataset in R script and put a filter on the date column, I am getting the below error which looks like it is being returned from ADO.NET. I am able to do the conversion just fine in native R. Any idea what is going wrong here? I tried to convert this column into datetime and use as.Date(<columnName>) > Sys.Date()-1 as well. But nothing seems to work,

 

Here is the line of code which is throwing this error:

 

subData <- subset(dataset, as.Date(ProcuredOn) > Sys.Date()-1)
1 ACCEPTED SOLUTION

I managed to get that filter working by reloading the dataset and configuring the intermediate steps again from scratch. Strange though. The error message that I got earlier said something like "Invalid data conversion". I guess it was something related to some other column which got it's type changed in between the steps. 

View solution in original post

3 REPLIES 3
v-ljerr-msft
Employee
Employee

Hi @karun_r,


@karun_r wrote:

I have a dataframe which holds a column with date values. The datatype for this column is date in Power BI. When I try to modify this dataset in R script and put a filter on the date column, I am getting the below error which looks like it is being returned from ADO.NET.

 


What's the error message? I haven't found it in your post above. Smiley Happy

 

I have tested the R script shared above on my Power BI Desktop(Version: 2.50.4859.502 64-bit (September 2017)). It seems to work for me without any issue.

 

r3.PNG

 

Could you share a sample pbix with just some sample/mock data which can reproduce the issue.? So that we can help further investigate on it. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading. Smiley Happy

 

Regards

I managed to get that filter working by reloading the dataset and configuring the intermediate steps again from scratch. Strange though. The error message that I got earlier said something like "Invalid data conversion". I guess it was something related to some other column which got it's type changed in between the steps. 

Hi @karun_r,

 

Great to hear the problem got resolved! Could you accept your last reply above as solution to close this thread? Smiley Happy

 

Regards

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.