skip to main content
Power BI
    • What is Power BI
    • Why Power BI
    • Customer stories
    • Data visuals
    • Security
    • Power BI Desktop
    • Power BI Pro
    • Power BI Premium
    • Power BI Mobile
    • Power BI Embedded
    • Power BI Report Server
  • Pricing
    • Azure + Power BI
    • Office 365 + Power BI
      • Energy
      • Healthcare
      • Manufacturing
      • Media
      • Retail
    • For analysts
    • For IT
      • Overview
      • Embedded analytics
      • Power BI visuals
      • Automation
      • Documentation
      • Community
    • Overview
    • Find consulting services
    • Partner showcase
    • Find a partner
    • Become a partner
    • Instructor-led training
    • Getting started
      • Overview
      • Online workshops
      • Self-guided learning
      • Webinars
      • Documentation
      • Roadmap
      • Overview
      • Issues
      • Give feedback
    • Blog
    • Business intelligence topics
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • Events
    • User groups
    • Community blog
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Galleries
    • Community Connections & How-To Videos
    • COVID-19 Data Stories Gallery
    • Themes Gallery
    • Data Stories Gallery
    • R Script Showcase
    • Webinars and Video Gallery
    • Quick Measures Gallery
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power BI Community
    • Galleries
    • R Script Showcase
    • Re: Schedule view

    Re: Schedule view

    10-23-2017 02:57 AM

    C_Houghton
    Frequent Visitor
    20782 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    fathomson
    fathomson Advocate II
    Advocate II
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    Schedule view

    ‎09-16-2016 03:18 AM

    schedule

     

    Description

    A relatively simple visualization to show start-stop of events at locations. Can be roomscheduling but also a production process with specific states at a given time. Although it is only a few lines of R I've used it several times and think it is worth sharing!
      

    Prerequisites (The sample .pbix files will not work without these prerequites completed)

    1. Install R Engine

    Power BI Desktop does not include, deploy or install the R engine. To run R scripts in Power BI Desktop, you must separately installR on your local computer. You can download and install R for free from many locations, including the Revolution Open download page, and the CRAN Repository.

     

    2. Install the required R packages.

    Download the R script attached to this message and run it to install all required packages on your local machine. 

     

    Required R packages:

    ggplot2


    Tested on:

    CRAN 3.3.1, MRO 3.3.0, powerbi.com

    Preview file
    21 KB
    schedules_in_powerbi_with_r.pbix
    Labels:
    • Labels:
    • General R Visualizations
    Message 1 of 16
    47,597 Views
    10
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    C_Houghton
    C_Houghton
    Frequent Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-19-2017 07:39 AM

    This is exactly what I'd like to use, but I want to define limits to ensure a whole day is shown, even if the schedule only has 1 item half an hour long. 

     

    Do you have any ideas on dynamically changing the scale? I'm currently using it with a Calendar visual allowing you to select days, which means it could be any day, so it needs a limit for x hours in a variable date 😕

     

    Another possible option (not ideal at all) is to add a placeholder for every day that is 24 hours long!

    Preview file
    62 KB
    Message 11 of 16
    44,828 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to C_Houghton
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-22-2017 05:15 AM

    Hi @C_Houghton, 

     

    You certainly can use ggplot functionality to get the required feature. 

    BTW,  @fathomson implmented R Custom Visual on the basis of this show case. 

    It is still available here. 

     

    As a quick and dirty "hack" to your problem you may try to add two zero-length resources at the beginning and the end of the day. 

     

     

    Message 12 of 16
    20,800 Views
    0
    Reply
    C_Houghton
    C_Houghton
    Frequent Visitor
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-23-2017 12:58 AM

    Thanks for your reply! That would be absolutely perfect, but i'm getting errors:

     

    Feedback Type:
    Frown (Error)

    Timestamp:
    2017-10-23T07:56:28.6198256Z

    Local Time:
    2017-10-23T08:56:28.6198256+01:00

    Product Version:
    2.47.4766.801 (PBIDesktop) (x64)

    Release:
    June 2017

    IE Version:
    11.608.15063.0

    OS Version:
    Microsoft Windows NT 10.0.15063.0 (x64 en-GB)

    CLR Version:
    4.6.2. or later [Release Number = 460798]

    Workbook Package Info:
    1* - en-US, Query Groups: 0, fastCombine: Disabled, runBackgroundAnalysis: True.

    Peak Working Set:
    386 MB

    Private Memory:
    271 MB

    Peak Virtual Memory:
    33.8 GB

    Error Message:
    R script error.
    Loading required package: ggplot2
    Loading required package: grid
    Loading required package: gridExtra
    Warning message:
    package 'gridExtra' was built under R version 3.4.2
    Loading required package: wesanderson
    Warning message:
    package 'wesanderson' was built under R version 3.4.2
    Loading required package: RColorBrewer
    Loading required package: dplyr
    Warning messages:
    1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
    there is no package called 'dplyr'
    2: In libraryRequireInstall("dplyr") :
    *** The package: 'dplyr' was not installed ***
    Error in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
    factor level [2] is duplicated
    Calls: sortDataset -> factor
    Execution halted


    User ID:
    db15c5fa-a129-4ae0-ba08-f5149b97bbcb

    Session ID:
    89517680-55f3-4784-b47f-0655edbd950b

    Telemetry Enabled:
    True

    Model Default Mode:
    Import

    Snapshot Trace Logs:
    C:\Users\ch1\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot293130851.zip

    Performance Trace Logs:
    C:\Users\ch1\AppData\Local\Microsoft\Power BI Desktop\PerformanceTraces.zip

    Enabled Preview Features:
    PBI_Snowflake
    PBI_shapeMapVisualEnabled
    PBI_EnableReportTheme
    PBI_allowBiDiCrossFilterInDirectQuery
    PBI_pivotTableVisualEnabled
    PBI_numericSlicerEnabled
    PBI_daxTemplatesEnabled
    PBI_relativeDateSlicer
    CustomConnectors

    Disabled Preview Features:
    PBI_SpanishLinguisticsEnabled
    PBI_PbiServiceLiveConnect

    Disabled DirectQuery Options:
    PBI_DirectQuery_Unrestricted

    Cloud:
    GlobalCloud

    Time:
    Mon Oct 23 2017 08:55:49 GMT+0100 (GMT Summer Time)

    Client Error Code:
    ServiceErrorToClientError

    Error Details:
    R script error.
    Loading required package: ggplot2
    Loading required package: grid
    Loading required package: gridExtra
    Warning message:
    package 'gridExtra' was built under R version 3.4.2
    Loading required package: wesanderson
    Warning message:
    package 'wesanderson' was built under R version 3.4.2
    Loading required package: RColorBrewer
    Loading required package: dplyr
    Warning messages:
    1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
    there is no package called 'dplyr'
    2: In libraryRequireInstall("dplyr") :
    *** The package: 'dplyr' was not installed ***
    Error in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
    factor level [2] is duplicated
    Calls: sortDataset -> factor
    Execution halted


    Stack Trace:
    Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: R script error.
    Loading required package: ggplot2
    Loading required package: grid
    Loading required package: gridExtra
    Warning message:
    package 'gridExtra' was built under R version 3.4.2
    Loading required package: wesanderson
    Warning message:
    package 'wesanderson' was built under R version 3.4.2
    Loading required package: RColorBrewer
    Loading required package: dplyr
    Warning messages:
    1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
    there is no package called 'dplyr'
    2: In libraryRequireInstall("dplyr") :
    *** The package: 'dplyr' was not installed ***
    Error in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
    factor level [2] is duplicated
    Calls: sortDataset -> factor
    Execution halted

     

    Any insights off the bat? Or I can follow it up with the creator.

     

    Thanks again

    Message 13 of 16
    20,790 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to C_Houghton
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-23-2017 02:42 AM

    Hi @C_Houghton, 

     

    *** The package: 'dplyr' was not installed *** 

     

    Try to install it manually from RStudio

     

    > install.packages("dplyr") 

     

    Message 14 of 16
    20,785 Views
    0
    Reply
    C_Houghton
    C_Houghton
    Frequent Visitor
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-23-2017 02:57 AM

    Hi there,

     

    I installed that package - looks slightly better:

     

    Error Details:

    R script error.

    Loading required package: ggplot2

    Loading required package: grid

    Loading required package: gridExtra

    Warning message:

    package 'gridExtra' was built under R version 3.4.2

    Loading required package: wesanderson

    Warning message:

    package 'wesanderson' was built under R version 3.4.2

    Loading required package: RColorBrewer

    Loading required package: dplyr

     

    Attaching package: 'dplyr'

     

    The following object is masked from 'package:gridExtra':

     

        combine

     

    The following objects are masked from 'package:stats':

     

        filter, lag

     

    The following objects are masked from 'package:base':

     

        intersect, setdiff, setequal, union

     

    Error in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :

      factor level [2] is duplicated

    Calls: sortDataset -> factor

    Execution halted 

    Message 15 of 16
    20,782 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to C_Houghton
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎12-12-2017 11:54 PM

    Hi, 

    Make sure Dates are not hierarchies and no summary applied on other fields. 

    You welcome to send me the PBIX and I'll have a look . 

    boefraty @  microsoft  .  com 

    Message 16 of 16
    20,711 Views
    0
    Reply
    numbersei
    numbersei
    Frequent Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-17-2017 01:20 AM

    Good morning!

     

    Congrats for the great job. 🙂

    It is very useful for me.

    One question: where is defined the variable datetime_start?

     

    ggplot(dataset,aes(x=datetime_start, y=dataset$Room, color=Person)) +
      geom_segment(aes(x=From,xend=To,yend=dataset$Room),size=15) +
      scale_colour_discrete(guide=guide_legend(override.aes=list(size=10))) +
    ggtitle("Room reservations for building X") + xlab("") + ylab("") + theme_bw()

     

    Thanks for your time! 🙂

    Message 9 of 16
    44,862 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to numbersei
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-22-2017 05:08 AM

    Hi @numbersei, 

    Sorry for delay in reponse. Do you still need help to your project? 

    To your question datetime_start is a typo in code. Luckily it was ignored by ggplot because aes is replaced. 

    Message 10 of 16
    20,800 Views
    0
    Reply
    jmpace
    jmpace
    New Member
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎07-13-2017 04:59 PM

    Hey, I'm so green with R, I was wondering if you might be able to give me a head start. Literally, I started looking at it today after I saw your post.

     

    How would you adapt this to a production process? That's what I want to do.

    Say products "A" and "B" entering various different stages (1, 2, 3) of the development process.

     

    Any head start would be really appreciated.

     

    As a side note, it looks like your data model in PBI is really simple! I like that! I would totally build a simple table based off of referenced queries.

    And you're just using a few lines of R to extract that and create the visual. It seems very cool!

    Message 7 of 16
    45,630 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to jmpace
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-22-2017 04:51 AM

    Hi @jmpace, 

    Did you get any help with your project? Sorry for late response. 

    Please contact me if you still need any help with it. 

     

    The developer of this visual @fathomson did an excelent job converting this R visual to custom visual. 

    Which is still available here. And I hope one day will be avaialble in AppSource.   BTW, please check if Gantt chart can be useful for you. 

     

      

    Message 8 of 16
    44,791 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎11-22-2016 02:36 AM

    Hi Frank,

    Thanks for your new R-showcases. They are very useful.  If you consider to convert some of your R-visuals to R-powered-custom visuals, out team will be happy to assist you. 

     

    The visibility of R-powered custom visuals is greater and it is not limited for R-users. 

    Message 6 of 16
    46,897 Views
    0
    Reply
    PolymathConsult
    PolymathConsult
    Regular Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-25-2016 07:07 AM

    This is great, exactly what I was looking for. I am quite new tto R, but was wondering......using the below script:

     

    ## Show schedule of projects by start / end date
    #

    library(ggplot2) # Visualization

    # Convert timestamp to POSIXct. What do I do here to make the x-axis format to show yyyy/mm/dd? or alternatively mmm-yy?
    dataset$From<-as.POSIXct(dataset$From,format="%Y-%m-%dT%H:%M:%OS")
    dataset$To<-as.POSIXct(dataset$To,format="%Y-%m-%dT%H:%M:%OS")

    ggplot(dataset,aes(x=datetime_start, y=dataset$Room, color=Person)) +
    geom_segment(aes(x=From,xend=To,yend=dataset$Room),size=15) +
    scale_colour_discrete(guide=guide_legend(override.aes=list(size=10))) +
    ggtitle("Room reservations for building X") + xlab("") + ylab("") + theme_bw()

     

    Thanks again and keep up the good work!!

     

    Kind Regards, 

    Llewellyn

    Message 4 of 16
    47,109 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to PolymathConsult
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎10-27-2016 04:36 PM

    @PolymathConsult,

    Try adding a datetime scale similar to below:

    scale_x_datetime(breaks = date_breaks("1 month"), labels=date_format("%d/%m/%Y"))

     You may also want to turn the date on the X axis for easier reading

    theme(axis.text.x = element_text(angle = 90))

     

    P.S. You'll need to load library(scales) to use the scale_x_datetime function... 

    Message 5 of 16
    47,084 Views
    1
    Reply
    mike_honey
    mike_honey Memorable Member
    Memorable Member
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎09-21-2016 07:15 PM

    There doesnt appear to be any R packages attached to this topic?

    Message 2 of 16
    47,326 Views
    0
    Reply
    fathomson
    fathomson Advocate II
    Advocate II
    In response to mike_honey
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎09-27-2016 02:41 AM

    Hi Mike,

     

    The R code is inside the powerbi dashboard file. 

     

    Message 3 of 16
    47,287 Views
    0
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Automate
    • Power Virtual Agents

    • Sign in
    • Sign up

    Browse

    • Solutions
    • Partners
    • Consulting Services

    Downloads

    • Power BI Desktop
    • Power BI Mobile
    • Power BI Report Server
    • See all downloads

    Learn

    • Guided learning
    • Documentation
    • Support
    • Community
    • Give feedback
    • Webinars
    • Developers
    • Blog
    • Newsletter

    © 2022 Microsoft

    Follow Power BI

    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks