Forum Discussion
jkraush1
9 years agoFrequent Visitor
Query Editor R Script errors
I uploaded a .xlsx file into Power BI desktop and tried to run a simple R script on it in query editor as a test run. Specifically the script I ran was: # 'dataset' holds the input data for this ...
- 9 years ago
Hi jkraush1,
I got the same error when using above script. In my test, the Date column is set to DateTime, formatted as "1/1/2017 5:20:20AM".
Please try below code.
Hour=format(as.POSIXct(dataset$Date, format="%Y-%m-%d %H:%M:%S"), format="%H")
Regards,
Yuliana Gu
BeardyGeorge
9 years agoAdvocate I
given the errors you're getting, it's possible the data isn't formatted as you're expecting (or pbi is changing it somewhere along the way) - would you be able to give us some examples of the data you have?
Thanks,
George.
- jkraush19 years agoFrequent Visitor
George,
It appears that power bi is changing how the data is formatted, from a datetime to a string. the as.POSIX code provided for me thankfully did not return an error