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
    • Association Rules

    Association Rules

    08-14-2016 15:27 PM - last edited 04-08-2018 01:51 AM

    Microsoft Sharon
    Microsoft
    69160 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    Sharon
    Microsoft Sharon
    Microsoft
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Association Rules

    ‎08-14-2016 03:27 PM

    report_assoc.JPGDescription

    Association rules are ideal to quicly derive insights from large datasets.  The rules are autmatically detected and visualized. 
     

    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:

    arules, arulesViz, grDevices, gridExtra, grid, methods


    Tested on:

    CRAN 3.3.1, MRO 3.3.0, , powerbi.com

     

    Legal Disclaimers:

    Terms of Service and Third Party Programs.

     

    Preview file
    6 KB
    ScriptInstallPackagesWithWorkaroundsAssorules.R
    Association Rules Showcase_1.0.2.pbix
    Labels:
    • Labels:
    • Advanced Analytics Visualizations
    Message 1 of 25
    69,160 Views
    7
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    ironryan77
    ironryan77 Advocate II
    Advocate II
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-10-2017 08:42 AM

    Great job on this visual!  But I can't figure out how you created your dataset?  I'm looking at the sample PBIX file and it looks like the selected fields are total counts.  So in my PBIX file I counted the total values by creating a measure:

    MPPL2 = CALCULATE(COUNT(IRC_Metric_RSA_Refresh[PPL2]), FILTER(IRC_Metric_RSA_Refresh, [PPL2]="AUTO"))

     

    But when I add this measure to the visual in my own PBIX file, it doesn't allow Basic filtering and it doesn't display in my PBIX.  How can I mimic your behavior in my PBIX file?

    Message 19 of 25
    32,547 Views
    0
    Reply
    ironryan77
    ironryan77 Advocate II
    Advocate II
    In response to ironryan77
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-10-2017 09:11 AM

    Also this is the error I'm getting:

    association rules error.jpg

    Message 20 of 25
    32,546 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to ironryan77
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-23-2017 12:42 AM

    Hi ironryan77, 

    Please send me a PBIX, I will see what can be done 

    Message 21 of 25
    32,519 Views
    1
    Reply
    ironryan77
    ironryan77 Advocate II
    Advocate II
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎04-24-2017 03:15 PM

    Thanks!

    Association Rules.pbix
    Message 22 of 25
    32,508 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to ironryan77
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎05-22-2017 06:44 AM

    Hi @ironryan77, 

    I am really sorry for late reply 😞 

    Apparently some changes/ updates in "arules" package caused the sub-function  "cleanRedundant" to work diffrently without backward compatability.  We will need to solve it both for R visual and R custom visual.  I will update and ping you after update. 

    Message 23 of 25
    32,422 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

    ‎04-06-2018 05:25 AM

    @boefraty I know this is a very old thread but I am getting the same error with this visual. Is there a way to fix it?

    Message 24 of 25
    30,343 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

    ‎04-08-2018 01:34 AM

    Hi @Anonymous and @Anonymous and @surething and @ironryan77 and @HowardCC

     

    I am really sorry for such a a late reply. The error in R-script is inside  cleanRedundant function

    The is.subset functionality changed with latest releases of arules package. 

    Quick and dirty fix is to comment out some lines in the function (attached solution) 

     

    Which means you still may get some redundant rules in output, will investigate in the future. 

     

    assorules_R_visual_ID_Product_synthetic_data_no_subset.pbix
    Message 25 of 25
    30,332 Views
    0
    Reply
    karaoan
    karaoan Kudo Commander
    Kudo Commander
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-05-2017 06:17 PM

    Hi, I have installed r (default version and one that I used is 3.3.2 though) as per provided links and ran the script. When refreshing the PBIX I get the following error:

    Preview file
    51 KB
    Message 17 of 25
    66,245 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to karaoan
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-06-2017 07:19 AM

    The problem is with "ISLR" package it is required by R connector (not R visual), so you have two workarounds:

    1) Don't do refresh

    2) call command
    install.packages("ISLR")

    from any R console

    Message 18 of 25
    66,236 Views
    0
    Reply
    baferrie
    baferrie
    New Member
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-26-2017 11:18 AM

    Hello, I downloaded the association rules custom viz and succesfully have it working with the data. I was wondering though if there was any way we could sort the rules based on the RHS? I tried adding a filter, but what that did was exclude the data from ever getting to the association rules algorithm. Is there a way to sort the association rules without excluding data?

    Message 10 of 25
    66,333 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to baferrie
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎02-08-2017 03:44 AM

    Side branch solution for this feature: 
    https://github.com/boefraty74/PowerBI-visuals-assorules-1/tree/assorulesWithTextFilters

     

     

    I added two text parameters, comma separated strings to be searched inside RHS string rule (using OR operator)

     

    CaptureTextFilter1.JPG

    CaptureTextFilter2.JPG

    Message 12 of 25
    32,611 Views
    0
    Reply
    MAAbdullah47
    MAAbdullah47 Helper V
    Helper V
    In response to boefraty
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎12-30-2017 10:02 PM

    Please tell us how you draw this table.

    Message 13 of 25
    31,684 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to MAAbdullah47
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-02-2018 05:42 AM

    Which table? There is a parameter 'visualisationMethod' in the script 

    Message 14 of 25
    30,472 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

    ‎03-22-2018 03:31 AM

    Hi,

     

    @boefraty I am trying to make it to works with my transactions data but it does not gives me any visualization for it.

     

    Any idea how to make it works?

     

    Mohammad PATEL

    Message 15 of 25
    30,385 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

    ‎03-25-2018 01:40 AM

    Hi @Anonymous, 

    Could you please send me your data sample or even PBIX with data included? 

    boefraty @ microsoft . com 

    Message 16 of 25
    30,369 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to baferrie
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-29-2017 01:10 AM

    Capture.JPG

    Do you want to sort by second column? 

    Message 11 of 25
    66,306 Views
    0
    Reply
    Anonymous
    Not applicable
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-21-2016 01:43 AM

    Hi

    I wonder if you can advice that what Im trying to acheive is possible.

     

    I wanted to transform my dataset to transactions using a simple R script below
    library(arules)

    dd = as(dataset, "transactions")
    df = as.data.frame(as(dd, "matrix"))

     

     

    However I got an error message beolow. Can you please help what this error actually mean and how to fix it?

     

    DataSource.Error: ADO.NET: R script error.
    Loading required package: Matrix

    Attaching package: 'arules'

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

        abbreviate, write

    Error: could not find function "as"
    Execution halted

    Details:
        DataSourceKind=R
        DataSourcePath=R
        Message=R script error.
    Loading required package: Matrix

    Attaching package: 'arules'

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

        abbreviate, write

    Error: could not find function "as"
    Execution halted

        ErrorCode=-2147467259
        ExceptionType=Microsoft.PowerBI.Radio.RScriptRuntimeException

    Message 2 of 25
    68,319 Views
    0
    Reply
    Anonymous
    Not applicable
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-22-2016 12:19 PM

    Answered by own question!

    library(arules)
    library(methods)
    data(dataset)
    dd1=as(dataset,"transactions")
    trans=dd1
    AdultData=as.data.frame(as(dd1, "matrix"))
    AdultData=cbind(id=1:nrow(AdultData),AdultData)

     

     

    replace data(Adult) with data(dataset) and R does the rest!.. didnt have eyes for details there.

     

     

     

    Message 3 of 25
    68,251 Views
    0
    Reply
    patoduck
    patoduck Helper III
    Helper III
    In response to Anonymous
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎11-11-2016 03:32 PM

    Hi,

     

    I have a table with 2 Columns ID and Product.

    I want to Edit the Script in R, but I can't get it to work

    How should it be the read.transactions statement?  

    > txn <- read.transactions(dataset, rm.duplicates= TRUE,format='basket',sep='','',cols =1)

     

    But I get this error...

    Error in readLines(file, encoding = encoding) : 'con' is not a connection

     

     

    Preview file
    127 KB
    Preview file
    11 KB
    Message 4 of 25
    66,857 Views
    0
    Reply
    boefraty
    Microsoft boefraty
    Microsoft
    In response to patoduck
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎11-22-2016 02:07 AM

    The data with 2 columns: "TransactionID" and "Product" is indeed very natural. Attached is the PBIX with R code suited to such input.

    The relevant data transformation is in lines

    nnn = names(dataset)

    transData <- as(split(dataset[,nnn[2]], dataset[,nnn[1]]), "transactions")

     

    The data in PBIX is synthetic.

    Capture.JPG

    assorules_R_visual_ID_Product_synthetic_data.zip
    assorules_R_visual_ID_Product_synthetic_data_no_subset.pbix
    Message 6 of 25
    66,749 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