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
    • Microsoft 365 + Power BI
    • Dynamics 365 + Power BI
      • Energy
      • Healthcare
      • Manufacturing
      • Media
      • Retail
    • For analysts
    • For IT
      • Overview
      • Embedded analytics
      • Power BI visuals
      • Automation
      • Documentation
      • Community
    • Getting started
      • Overview
      • 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
    • Microsoft Power BI Community
    • Welcome to the Community!
    • News & Announcements
    • Get Help with Power BI
    • Desktop
    • Service
    • Report Server
    • Power Query
    • Mobile Apps
    • Developer
    • DAX Commands and Tips
    • Custom Visuals Development Discussion
    • Health and Life Sciences
    • Power BI Spanish Community
    • Translated Spanish Desktop
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Training and Consulting
    • Instructor Led Training
    • 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
    • Ideas
    • Custom Visuals Ideas
    • Issues
    • Issues
    • Events
    • Upcoming Events
    • Community Engagement
    • T-Shirt Design Challenge 2023
    • Community Blog
    • Power BI Community Blog
    • Custom Visuals Community Blog
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    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
    • Venn Diagram

    Venn Diagram

    10-28-2016 07:55 AM

    jessicammoss
    Advocate I
    69069 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    jessicammoss
    jessicammoss Advocate I
    Advocate I
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Venn Diagram

    ‎10-28-2016 07:55 AM

    Venn diagrams show overlapping regions based on values within sets. The R visualization code provided in this Power BI desktop file will take a dynamic set of columns (based on the values you add in the fields pane), perform the overlap analysis, and display the diagram. This code will work with up to 5 columns.

     

    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 install R 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: VennDiagram
    Preview file
    49 KB
    VennDiagramWithR.pbix
    Labels:
    • Labels:
    • General R Visualizations
    Message 1 of 30
    69,069 Views
    6
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    Anonymous
    Not applicable
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-16-2018 01:48 PM

    When I click on your link,  AttachmentVennDiagramWithR.pbix, Power bi pops up with an error message. Can't see your code. (see attached screenshot) Does this still work or am I just doing it wrong? I wrote code in r that runs beautifully (in r). When I run it inn Power Bi, it gives me the same error message as I get when I click on your link.

     

    Any hints anyone?

     

     Here's my code and a screenshot of a small dataset (Venn_dummy)

     

    draw.triple.venn(area1 = nrow(subset(Venn_dummy, Felony == "Yes")), area2 = nrow(subset(Venn_dummy, Misdemeanor == "Yes")), area3 = nrow(subset(Venn_dummy, Ordinance == "Yes")),
    n12 = nrow(subset(Venn_dummy, Felony == "Yes" & Misdemeanor == "Yes")), n23 = nrow(subset(Venn_dummy, Misdemeanor == "Yes" & Ordinance == "Yes")),
    n13 = nrow(subset(Venn, Felony == "Yes" & Ordinance == "Yes")), n123 = nrow(subset(Venn, Felony == "Yes" & Misdemeanor == "Yes" & Ordinance == "Yes")),
    category = c("Felony Offenders", "Misdemeanor Offenders", "Ordinance Offenders"), lty = "blank", fill = brewer.pal(n = 3, name = "Dark2"))

    Preview file
    103 KB
    Preview file
    6 KB
    Message 7 of 30
    61,972 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-25-2018 01:26 AM

    Hi  @Anonymous  , I opened the attached PBIX it works fine for me. 

    1) Make sure you have  updated PBI desktop 

    2) Install install.packages("VennDiagram")   from your R IDE

    3) If problem persisits look at the Error (See Details) 

    4) You may debug the code in your R IDE from R Visual  Capture.PNG

     

    5) If your problem persisits send me your PBIX 
    boefraty at microsoft com 

    Message 8 of 30
    61,814 Views
    1
    Reply
    Anonymous
    Not applicable
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-25-2018 07:03 AM

    Hi Boefraty,

     

    Thank you for your helpful message.

     

     

    I got the Venn Diagram to work in Power Bi, but I can’t get the slicer to work with it. I’m supposed to do a demonstration on this next week (yikes). I’ve attached a screen shot. Can you give me any tips?

     

    Note: my data file has person-level data (not aggregate), and includes both charge data and demographic data (i.e. race).

     

    Also, VEnn help.PNGI don’t know what a BPIX is.

    Message 9 of 30
    61,805 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-26-2018 12:31 PM

    PBIX is an extension of file generated in PBI desktop . 

    If you send it to me  I will have no trouble to reproduce your problem on my side. 

    Message 10 of 30
    61,774 Views
    2
    Reply
    Anonymous
    Not applicable
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-27-2018 10:30 AM

    Thanks so much!

     

    ##This Venn diagram code is for use in the Power Bi demonstration. Run it from R from within Power Bi

    #set working directory i.e. the folder you are working out of
    setwd("H:/Eliel JBBS Sent")
    #set default library path - where to look for packages, which are also called libraries
    .libPaths("H:/R/win-library/3.4")

    #load Venn Diagram package

    library(VennDiagram)
    library("RColorBrewer")
    library(grid)
    library(futile.logger)
    #get Java so we can export to Excel
    Sys.setenv(JAVA_HOME = "C:/Program Files/Java/jdk1.8.0_151")

    library(xlsx)
    library(rJava)


    Venn <- read.xlsx("Venn.xlsx", sheetName = "Venn", header = TRUE, stringsAsFactors = FALSE)


    draw.triple.venn(margin = 0.1, area1 = nrow(subset(Venn, Felony == "Yes")), area2 = nrow(subset(Venn, Misdemeanor == "Yes")), area3 = nrow(subset(Venn, Ordinance == "Yes")),
    n12 = nrow(subset(Venn, Felony == "Yes" & Misdemeanor == "Yes")), n23 = nrow(subset(Venn, Misdemeanor == "Yes" & Ordinance == "Yes")),
    n13 = nrow(subset(Venn, Felony == "Yes" & Ordinance == "Yes")), n123 = nrow(subset(Venn, Felony == "Yes" & Misdemeanor == "Yes" & Ordinance == "Yes")),
    category = c("Felony Offenders", "Misdemeanor Offenders", "Ordinance Offenders"), lty = "blank", fill = brewer.pal(n = 3, name = "Dark2"))

    Preview file
    13 KB
    Message 11 of 30
    39,578 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-28-2018 04:23 AM

    I got your code to run in my PBI Desktop just fine.  You mentioned something about slicers. I can not reproduce your slicers from R script 😞 

     

    Can you attach your PBIX (PBI desktop report file) ?  

    VennWithR.pbix
    Message 12 of 30
    34,330 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-30-2018 07:44 AM

    Thanks so much.

     

    Yes, my Venn code works great. The slicer does not.

     

    I created a slicer for Race like I do for anything else in Power Bi (see attached screen shots) It's on the same page as my Venn Diagram, which I created in R. I expected that if I selected only "white" in the race slicer, it would filter out all the non-white subjects in my Venn diagram, just like it does for any other Power Bi visual.

     

    Isn't that how it's supposed to work?

     

    Thanks again,

     

    Jennifer

    Preview file
    28 KB
    Preview file
    37 KB
    Message 13 of 30
    34,319 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-30-2018 08:15 AM

    Try to change your R visual to "Table" visual. See how it responses to slicer. 

    OR

    Run the code with your filtered data in R IDE like RStudio (see my previous reply) and debug it 

    OR   

    Send me the PBIX 🙂 
     Capture.PNG

     

    Message 14 of 30
    34,316 Views
    1
    Reply
    Anonymous
    Not applicable
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-30-2018 08:30 AM

    Thank you so much! Here is my PBIX file.

     

    Also I'vew attached a screen shot of what happens when I change it to a table. Yes the slicer works, but the visual isn't useful anymore.

     

    Many thanks,

    Jennifer

    Venn Diagram Help.pbix
    Preview file
    17 KB
    Message 15 of 30
    34,312 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-30-2018 12:56 PM

    Hi @Anonymous,
    One more tip. You should add more columns to your R visual ,  so that each row  is unique. Otherwise  PBI visual  (any visual) will remove duplicates and your diagramm will be wrong.  Another option is to use ID column.  And make sure you do not aggregate fields. 
    "Do not summarize" for all input fields. 

    Message 17 of 30
    34,306 Views
    1
    Reply
    Anonymous
    Not applicable
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-01-2018 07:23 AM

    HI Again Boefraty,

     

    I did everything you asked, but now I'm getting a count of one per category. There is a unique id for each observation, but Power Bi is still deleting "duplicates".

     

    Here's the code and output, as well as a screenshot showing the unique ids.

     

    Many, many, many thanks,

     

    Juniper

     

    #set working directory i.e. the folder you are working out of
    setwd("H:/Eliel JBBS Sent")
    #set default library path - where to look for packages, which are also called libraries
    .libPaths("H:/R/win-library/3.4")

    #load Venn Diagram package

    library(VennDiagram)
    library("RColorBrewer")
    library(grid)
    library(futile.logger)


    #Venn <- read.xlsx("Venn.xlsx", sheetName = "Venn", header = TRUE, stringsAsFactors = FALSE)
    Venn = dataset

    draw.triple.venn(margin = 0.1, area1 = nrow(subset(Venn, Felony == "Yes")), area2 = nrow(subset(Venn, Misdemeanor == "Yes")), area3 = nrow(subset(Venn, Ordinance == "Yes")),
    n12 = nrow(subset(Venn, Felony == "Yes" & Misdemeanor == "Yes")), n23 = nrow(subset(Venn, Misdemeanor == "Yes" & Ordinance == "Yes")),
    n13 = nrow(subset(Venn, Felony == "Yes" & Ordinance == "Yes")), n123 = nrow(subset(Venn, Felony == "Yes" & Misdemeanor == "Yes" & Ordinance == "Yes")),
    category = c("Felony Offenders", "Misdemeanor Offenders", "Ordinance Offenders"), lty = "blank", fill = brewer.pal(n = 3, name = "Dark2"))

    Preview file
    70 KB
    Preview file
    41 KB
    Message 18 of 30
    34,294 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-04-2018 02:54 AM

    Hi @Anonymous, 

    I  really need the PBIX to see  the problem  😞

    Sounds like, you added the unique ID to data table, but you did not add the ID column as input to R visual. Drag the ID column to R visual as you did with "Felony" and the rest.  

    Message 19 of 30
    34,283 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-04-2018 12:48 PM

    Hi Boefraty,

     

    Thank you so much for your patience. Here is the PBIX file.

     

    I dragged the unique ID column to the R visual, but got the same result.

     

    Juniper

    Power Bi Venn.pbix
    Message 20 of 30
    34,275 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-05-2018 01:40 AM

    You missed my "tip" about making sure each column to be  "Don't summarize" . Working PBIX with filters is also attached Capture.PNG

     

    Power Bi Venn Works.pbix
    Message 21 of 30
    34,315 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-05-2018 10:33 AM

    Hi Boefraty,

     

    How large of a data set can a Venn Diagram handle in Power Bi?

     

    Many thanks,

     

    Juniper

    Message 24 of 30
    34,273 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-05-2018 11:33 PM

    Hi @Anonymous, 

    I am glad it worked out for you. Here are limitations of R visuals in PBI: 
    https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals#known-limitations

     

    Message 25 of 30
    34,271 Views
    1
    Reply
    Anonymous
    Not applicable
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-06-2018 09:50 AM

    Thank you so much!!!

    Message 26 of 30
    34,265 Views
    0
    Reply
    spotpuff
    spotpuff
    Frequent Visitor
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-09-2018 12:17 AM

    This visual appears to give incorrect results when 4 fields are selected.

    I can do 3 just fine but 4 doesn't calculate properly, e.g., a category with 30 items shows 20, 4, 0, 0 instead of adding to 30.

    My math could be off, though. I think with 4 categories there's no way to actually show the top & bottom categories (or left & right) intersecting since they already overlap in the middle.  Maybe that's just a limitation of Venn diagrams; in that case maybe limit it to 3 categories?

     

    3 categories: correct figures; each category adds to 8.3 categories: correct figures; each category adds to 8.4 categories: Something is wrong; categories add  to 7.4 categories: Something is wrong; categories add to 7.


    Data is standard 4 variable w/ 2 options per variable.Data is standard 4 variable w/ 2 options per variable.

    Message 27 of 30
    34,164 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to spotpuff
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-09-2018 05:09 AM

    Hi @spotpuff, 

    Please make sure all the rows in your input table are UNIQUE. You can do it by adding ID column (but ignore it in R script). 

    Message 28 of 30
    34,150 Views
    0
    Reply
    spotpuff
    spotpuff
    Frequent Visitor
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-09-2018 06:12 AM

    The rows are unique; I was using an illustrative example but I was using the diagram on a real dataset which has a row ID type field and I was still having problems with the 4 dimensional Venn diagram.

     

    The issue is likely something to do with more than 3 categories requiring strange diagrams:

    https://en.wikipedia.org/wiki/Venn_diagram#Extensions_to_higher_numbers_of_sets

     

    The visual doesn't make the 4th category into that "rainbow" type thing, so the math might be off.

     

    Or I might be wrong.

    Either way for now I'm sticking with 3 categories as the math works out in that diagram.

    Message 29 of 30
    34,144 Views
    0
    Reply

    Power Platform

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

    • Sign in
    • Sign up

    Browse

    • Solutions
    • 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

    © 2023 Microsoft

    Follow Power BI

    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks
    Consumer Privacy Act (CCPA) Opt-Out Icon Your Privacy Choices