Forum Discussion
PowerBI query export table using R script
- Anonymous2 years ago
Hi Tinus1905 ,
Please try:
# 'dataset' holds the input data for this script # Get the current date and time now <- Sys.time() # Format the date to get the ISO week number and year week <- strftime(now, "%V-%Y") # Create the file path with the new naming convention Table <- paste0("\\\\af01\\Users\\Tinus\\Desktop\\new\\TEST", week, ".csv") # Write the dataset to the file write.table(dataset, file = Table, sep = ";", na = "", row.names = FALSE, quote = FALSE) ```Please note that %V gives you the ISO week number, and %Y gives you the year. Make sure that your system's locale settings support the %V format specifier for week number. If not, you may need to use an alternative method to calculate the week number. After making these changes, your script should export the table to a CSV file with the naming convention you desire (e.g., "TEST48-2023.csv").
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 2 years ago
Anonymous this is perfect.
Is it also possible in the R script to send the export as an attachement directly with email?
Anonymous this is perfect.
Is it also possible in the R script to send the export as an attachement directly with email?
Hi Tinus1905 ,
To export data from Power BI into a file using R, you can use the gdata package. To send an email with an attachment using R, you can use the mailR package.
Please refer: Export Data from Power BI into a file using R - Ben's Blog (datakuity.com)
how do you send email from R - Stack Overflow
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Tinus19052 years agoResolver I
I made a R script for email and that is ok, but now I want the attachment to be the file that is exporting from the other R script.
So now I have: a table (every previous week) -> R script for export to CSV.
What I want: a table (every previous week) -> R script for export to CSV -> email the CSV as an attachment.
- Anonymous2 years agoNot applicable
Hi Tinus1905 ,
In order to better solve your problem, please open a new case, we recommend a case to solve only one problem, because this can get with good help, and also to give other users a better reference!
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Tinus19052 years agoResolver I
Thanks. I opend a new case.