# Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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)

- 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
- Install the required R packages: VennDiagram

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-22-2016 02:44 AM

Hi Jessica,

Thanks for this wonderful R-showcase. If you consider to convert this or one of your future 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.

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-21-2017 11:01 PM

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-23-2017 03:12 AM

Try changing parameters of

venn.diagram

For example margin:

venndiagram <- venn.diagram(listdataset, filename=NULL, na="remove", fill = listcolor, margin = 0.1)

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-26-2017 10:40 PM

Thanks!

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-16-2018 01:48 PM

When I click on your link, VennDiagramWithR.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"))

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-25-2018 01:26 AM

Hi @juniper , 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

5) If your problem persisits send me your PBIX

boefraty at microsoft com

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- 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, I don’t know what a BPIX is.

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- 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.

## Re: Venn Diagram

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- 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"))