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
    • Events
    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: Matrix Bubble Chart

    Re: Matrix Bubble Chart

    07-14-2022 18:12 PM

    CloudHerder
    Helper II
    475 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    plainly
    plainly
    Regular Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    Matrix Bubble Chart

    ‎02-23-2021 06:33 AM

    What

    A powerful Power BI R visual, matrix bubble chart, to analyze three measures (facts) with two selected dimensions.

     

    Power BI R Matrix Bubble Chart Sales Opportunity AnalysisPower BI R Matrix Bubble Chart Sales Opportunity Analysis

     

     

     

    How

    One needs to have R installed on the computer or to the server / enabled in the cloud environment. 

    Here is a guide to get started: https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-r-visuals
    Here is a link to some details: https://docs.microsoft.com/en-us/power-bi/visuals/service-r-visuals

     

    Analysis example

    • The edge color of a bubble tells about the margin % of a product.
    • The fill color of a bubble tells about the % of opportunities won (hitrate) of a product.
    • The bubble size illustrates the number of the opportunities.
    • In the X-axis is the product dimension.
    • In the Y-axis is the free feature bundle given together with the product dimension.

    This could be an example from the car industry. The question could be what bundles we want to offer with what products and how should we price the product & bundle combinations.

     

    See my blog post for an example use case:

    https://www.plainlyresults.com/blog/power-bi-r-matrix-bubble-chart-sales-opportunity-analysis/

     

    CODE

    Add in your Power BI R visual the code below the "Paste or type your script code here:" text.


    #change lib path to were you have ggplot2 and scales installed
    library(ggplot2, lib="D:/Program Files/R/R-3.6.3/library")
    require(ggplot2)
    library(scales, lib="D:/Program Files/R/R-3.6.3/library")

    #change columns Product, Free_feature_bundle, dataset$... to your columns in the Power BI model selected to the R visual
    ggplot(dataset, aes(x = Product, y = Free_feature_bundle, label = paste(round(dataset$Opportunity_count, digits=0), round(dataset$Hitrate_perc, digits=2)*100, round(dataset$Margin_perc, digits=2)*100, sep=";"))) +
    geom_point(shape = 21, aes(size = round(dataset$Opportunity_count, digits=0) , fill = round(dataset$Hitrate_perc, digits=2)*100, color = round(dataset$Margin_perc, digits=2)*100, stroke = 3)) +
    geom_text(hjust = 1, size = 4) +
    scale_size(range = c(15,50)) + #scaling of the bubbles
    theme_bw()+ scale_fill_gradient2("Hitrate % (fill)", low=muted("red"), high=muted("green"), midpoint =
    mean(dataset$Hitrate_perc*100)) +theme_bw()+ scale_color_gradient2("Margin % (edges)", low=muted("red"),
    high=muted("green"), midpoint = mean(dataset$Margin_perc*100)) + labs(size = "Number of opportunities (size)")

     

    R_matrix_bubble_chart_example.pbix
    Labels:
    • Labels:
    • Advanced Analytics Visualizations
    • General R Visualizations
    Message 1 of 3
    2,467 Views
    0
    Reply
    • All forum topics
    • Next Topic
    nehajadhav166
    nehajadhav166 Helper II
    Helper II
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎04-07-2022 08:21 AM

    Hi,

    I am trying to create a chart but I am stuck while running the script, the error is "

    nehajadhav166_0-1649344856761.png

    can you please help me to proceed? 

     

    Thanks,

    Neha

    "

    Message 2 of 3
    1,114 Views
    0
    Reply
    CloudHerder
    CloudHerder Helper II
    Helper II
    In response to nehajadhav166
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    ‎07-14-2022 06:12 PM

    @nehajadhav166 Assuming that ggplot2 and scales packages are installed, try modifying the R script and remove or comment out the lib= instructions, like this:

    # if R is already in your path, you do not need the lib= instruction
    library(ggplot2) #, lib="D:/Program Files/R/R-3.6.3/library")
    require(ggplot2)
    library(scales) #, lib="D:/Program Files/R/R-3.6.3/library")

    That worked for me.
    Good luck!

    Message 3 of 3
    475 Views
    1
    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