Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I've created a R visual that load data and makes calendar. Everything is working fine in desktop.
But in service i get an error: Error in as.POSIXlt.default(x, tz = tz) : do not know how to convert 'x' to class "POSIXlt"
Date is just a table of dates:
Date
2019-01-01
2019-01-03
2019-01-02
2019-01-04
2019-01-05
How can I solve this?
Thanks in advance!
Solved! Go to Solution.
Hi @paltus ,
According to error message, it sounds like data format not recognized correctly on power bi service. You can refer to following link to use 'as.Date' or 'as.POSIXlt' functions to convert these date values :
library(ggplot2) dfr <- dataset dfr$day <- factor(strftime(as.POSIXlt(dfr$Date,format = "%Y-%d-%m"),format="%A"),levels=c("Sunday","Saturday","Friday","Thursday","Wednesday","Tuesday","Monday")) dfr$week <- factor(strftime(as.POSIXlt(dfr$Date,format = "%Y-%d-%m"),format="%V")) dfr$month <- factor(strftime(as.POSIXlt(dfr$Date,format = "%Y-%d-%m"),format="%B"),levels=c("January","February","March","April","May","June","July","August","September","October","November","December")) dfr$ddate <- factor(strftime(as.POSIXlt(dfr$Date,format = "%Y-%d-%m"),format="%d")) # plot p <- ggplot(dfr,aes(x=week,y=day))+ geom_text(aes(label=paste(ddate,sep =" ")))+ scale_fill_manual(values=c("#8dd3c7","#ffffb3","#fb8072","#d3d3d3"))+ facet_grid(~month,scales="free",space="free")+ labs(x="Week",y="")+ theme_bw(base_size=12)+ theme(legend.title=element_blank(), panel.grid=element_blank(), panel.border=element_blank(), axis.ticks=element_blank(), strip.background=element_blank(), legend.position="top", legend.justification="right", legend.direction="horizontal", legend.key.size=unit(0.4,"cm"), legend.spacing.x=unit(0.3,"cm")) plot(p)
Regards,
Xiaoxin Sheng
Hi @paltus ,
According to error message, it sounds like data format not recognized correctly on power bi service. You can refer to following link to use 'as.Date' or 'as.POSIXlt' functions to convert these date values :
library(ggplot2) dfr <- dataset dfr$day <- factor(strftime(as.POSIXlt(dfr$Date,format = "%Y-%d-%m"),format="%A"),levels=c("Sunday","Saturday","Friday","Thursday","Wednesday","Tuesday","Monday")) dfr$week <- factor(strftime(as.POSIXlt(dfr$Date,format = "%Y-%d-%m"),format="%V")) dfr$month <- factor(strftime(as.POSIXlt(dfr$Date,format = "%Y-%d-%m"),format="%B"),levels=c("January","February","March","April","May","June","July","August","September","October","November","December")) dfr$ddate <- factor(strftime(as.POSIXlt(dfr$Date,format = "%Y-%d-%m"),format="%d")) # plot p <- ggplot(dfr,aes(x=week,y=day))+ geom_text(aes(label=paste(ddate,sep =" ")))+ scale_fill_manual(values=c("#8dd3c7","#ffffb3","#fb8072","#d3d3d3"))+ facet_grid(~month,scales="free",space="free")+ labs(x="Week",y="")+ theme_bw(base_size=12)+ theme(legend.title=element_blank(), panel.grid=element_blank(), panel.border=element_blank(), axis.ticks=element_blank(), strip.background=element_blank(), legend.position="top", legend.justification="right", legend.direction="horizontal", legend.key.size=unit(0.4,"cm"), legend.spacing.x=unit(0.3,"cm")) plot(p)
Regards,
Xiaoxin Sheng
Hi, @Anonymous
Thank You for Your advice.
Everything now works fine, when i use only dates, but when i try to add measure i get an error.
dataset example:
Data CR
2019-01-01 50000
2019-01-03 60000
2019-01-02 40000
2019-01-04 30000
2019-01-05 21000
In service i get only Data, not Data + CR
If i write geom_text like this:
Can You help me with this problem,please?
Thank You
HI @paltus ,
I'd like to suggest you to refer to following link about geom_lable function:
Regards,
Xiaoxin Sheng
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
26 | |
19 | |
19 | |
13 | |
12 |
User | Count |
---|---|
30 | |
21 | |
19 | |
18 | |
15 |