Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Power BI and R

I have Power BI data as follows:

flights attribute Value

EmiratesETA9/09/2021 12:30
EmiratesArr Time9/09/2021 14:50:00 PM
Turkish AirlinesETA9/09/2021 17:30:00 PM
Turkish AirlinesArr Time9/09/2021 18:50:00 PM
Cathay PacificETA9/09/2021 19:30:00 PM
Cathay PacificArr Time9/09/2021 14:50:00 PM
Qatar AirwaysETA9/09/2021 20:30:00 PM
Qatar AirwaysArr Time9/09/2021 20:50:00 PM
LefthansaETA9/09/2021 12:30:00 PM
LefthansaArr Time9/09/2021 13:50:00 PM

 

I need to create a chart in Power BI, flights in x axis, time in y axis and attribute as the fill.

After researching a couple of days, to pot time in y axis the only solution I could find was R.

 

I changed the data type of column Value to Time and also converted time to integer using the formula below:

 

Column = HOUR('Query4 (2)'[Value])*3600+minute('Query4 (2)'[Value])*60 + SECOND('Query4 (2)'[Value])
 
My graph in R now shows time as integer, how do I display time instead of integer number.
 
ara_4_0-1631676922383.png

The R code I've used is below:

 

library(ggplot2)
library(hms)
library(plotly)

c1_graph <- ggplot(dataset, aes(workflow_code,Column, fill= Attribute, label=Value))+
#scale_y_time(limits = c(as.POSIXct(as_hms("09:00:00")), as.POSIXct(as_hms("13:30:00"))))+
geom_col(width=0.4, position=position_dodge(width=0.5))+
coord_flip()
c1_graph

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , refer if this can help

https://www.groundflooranalytics.com.au/resources/power-bi/custom-axis-formats-using-r-visuals

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi,

 

I need to create a interval on y-axis for the chart which I've produced in Power BI using R.

ara_4_0-1631171595604.png

AS you can see in the above image, in y-axis it displays all the time intervals. Instead I only want it to list every hour so that my chart will look neater.

 

Help is greatly appreciated.

 

Regards,

aRa

@Anonymous , for that, create a column in your table having only hour and use that in R visual

 

Hour = time(hour(column]),0,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks @amitchandak  The writeup helped.

amitchandak
Super User
Super User

@Anonymous , refer if this can help

https://www.groundflooranalytics.com.au/resources/power-bi/custom-axis-formats-using-r-visuals

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.