# Correlation Plot

08-14-2016 06:15 AM - last edited 11-16-2016 01:32 AM

# Correlation Plot

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

08-14-2016 06:15 AM - last edited on 11-16-2016 01:32 AM by boefraty

**Description**

Correlation plots can be used to quickly find insights, showing what otherwise would require lots of iterative slicing and dicing of your data.

Download this sample to see how a correlation plot can inform marketing strategies in different market segments.

**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.

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

**Required R packages:**

corrplot

**Tested on:**

CRAN 3.3.1, MRO 3.3.0, powerbi.com

**Legal Disclaimers:**

*Terms of Service **and **Third Party Programs**.*

## Re: Correlation Plot

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

09-14-2016 10:51 PM

This is a great R visual. I have taken some time to build a complete tutorial on how to 1. Install R, 2. add R code to PowerBI, 3. Manipulate the code to change the visual. You can follow along and learn how to build this here (www.PowerBI.Tips).

Enjoy,

Mike

mike@PowerBI.Tips

## Re: Correlation Plot

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

11-22-2016 01:44 AM

Great tutorial ! Here is another useful resource: https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-r-powered-custom-visuals/#troubles...

## Re: Correlation Plot

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

04-07-2017 01:21 PM

I love what you did here with this visual and it works perfectly in my PowerBI Desktop. However, when I try to view this from Power BI intranet, I get this error. I have tried to correct this by modifying the function and corrplot lines of code, with no success:

#verify if the column is numeric and non-constant correctColumn <- function(someColumn) { !is.null(someColumn) && is.numeric(someColumn) && length(unique(someColumn)) > 1 }

corrplot(M, method=method, order=order, type=type, addrect=addrect, #na.label = "?", na.rm=TRUE, mar = defMar, tl.col = tl.col, tl.cex=tl.cex, tl.srt=60, cl.ratio=0.2, cl.align="r", number.digits=number.digits, number.cex=number.cex, addCoef.col=addCoef.col)

How can I fix this?

## Re: Correlation Plot

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

04-23-2017 12:39 AM

## Re: Correlation Plot

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

04-24-2017 02:13 PM

Thanks, but I think I got this working now!

## Re: Correlation Plot

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

04-27-2017 08:06 AM

- How does corrplot calculate correlation matrices?
- Is this based on Pearson’s correlation coefficient formula? When I try plugging in my values to this formula, they do not match.
- Does corrplot remove duplicate rows?
- Does it handle aggregated columns?

## Re: Correlation Plot

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

04-27-2017 09:46 AM

Here is the documentation on the corrplot function that was used.

https://cran.r-project.org/web/packages/corrplot/corrplot.pdf

mike@PowerBI.Tips

## Re: Correlation Plot

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

06-07-2018 08:04 AM

Hi,

After reading your nice posts, I need some help.

(Sorry, I m beginner on Power BI).

I would like to build graphs or indicators in order to see correlations between countries in import trade according 2 variables : weights in TON and volumes in USD.

I added this code but it doesn't work :

require("corrplot")

library(corrplot)

M <- cor(dataset)

corrplot(M, method = "circle", tl.cex=0.6, tl.srt = 45, tl.col = "black", type= "upper", order="hclust")

If you have any suggestions, please advise.

Thank you in advance for your time and help,

Jaouad

## Re: Correlation Plot

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

07-12-2018 02:58 PM

For a while now, I am experiencing a problem with Correlation plot.

As I am using the same file sample with the same data and the same fields, but now importing the Correlation Plot visual from the visual market, I tried to replicate the same analysis, however, I always have the same error:

"Some columns are not numeric, or constant. Not enough input dimensions"

I have all the packages installed, everything, but always the same error, even if I type the code at the R script.

Any help with this?

Thank you in advance