Key driver analysis – What influences attrition?

Key driver/influencer analysis using the newly released Power BI “Key influencers” visual.

Key driver analysis or key influencer analysis is critical to understand what factors impact an outcome and/or what is the relative importance of a factor. Example:

What influences employee attrition? Overtime? Job Level?

What influences employee attrition in the Sales Executive role? Distance from home?

What influences customer attrition? High call rate? International Voice plan?

Knowing answers to above helps in decision making.

If employees in Job Role “Healthcare Representatives” leave the most because of the distance from home, maybe offer them fuel reimbursement or maybe offer them accommodation expenses if they stay near to office?


The newly released Power BI “Key influencers” visual (released as part of Feb 2019 Power BI Desktop release) aids such analysis very very quickly with no code! Crazy!

We applied this new visual to analyze what drives employee attrition, and I must say, I’m blown away by the outcome, ease of use, and comprehensiveness of the visual.

Download Power BI report and play with the visual.

But, how does the result look like?

From the visuals above we can clearly see what influences our variable Attrition=Yes. OverTime, MaritalStatus, YearsAtCompany, JobSatisfaction, and so on.

Not only that, the visual also provides the values of the factors which influences our variable of interest the most.

How to interpret the visual?

The likelihood of attrition increases by 2.93x if employees are doing overtime. Or, Attrition is 2.93x more likely in the employees who are doing overtime.

Hmm… if you do overtime, you may quit. This is obvious.

The attrition is 2.18x more likely if employees are single!

Attrition is also high if the Department is Sales.

And so on.

The left-hand side view of Key influencers shows all the factors influencing our “Attrition=Yes” by a factor of 1.0 and above.

The right-hand side view shows the distribution of data with respect to the selected factor and Attrition either as a column chart or a scatter plot.

The dashed line shows Avg. Attrition % of all values except for the key influencer one (in this case except for OverTime = Yes)

There is another view of this visual where we can see Top segments with high attrition % and their characteristics.

Top segments view in Key influencers visual in Power BI

The visual identified 4 segments with high attrition % along with population count. Clicking on a bubble shows us the characteristics of that segment.

Top segments deep dive

Segment 1 with Attrition % as 57.6 has employees in Department Sales, DistanceFromHome > 11, JobLevel is high and OverTime is Yes.

Wow!

You can further drill down this segment by clicking on “Learn more about this segment” and see what other factors influence this segment.

Quick FAQs on Key influencer visuals and its outcome

Can I filter this visual?

Yes, you can. Example: Why are employees in job role “Healthcare Representative” leaving the company?

Filter the visual and the analysis changes!

Is the visual interactive?

Yes, you can select individual influencing factors and see the distribution of Attrition % by the selected factor.

Can I hover over the values in the scatter plot above?

Yes, you can!

Can I see the logic or p-values associated with factors or key influencers?

No, not yet. This visual is in preview mode. Power BI team may add this feature in the future. Not sure about this.

Can I just see the top X key influencers?

No, not yet. This visual is in preview mode. Power BI team may add this feature in the future. Not sure about this.

I do not see my key influencer in this visual?

Yes, this can happen. Based on my R code using RandomForest, Age should also be an influencing factor for attrition but doesn’t show up in Power BI visual.

See this scatter plot. If Age decreases, Attrition % increases. Maybe Power BI just checks how the “increase” direction of a factor increases Attrition % or Maybe the number of data points for lower age and high attrition is less. 

As Age decreases, Attrition % increases

Can I export the data for segments?

No, not yet. This visual is in preview mode. Power BI team may add this feature in the future. Not sure about this.

Does this visual analyze multiple factors and provide conclusions?

I do not think so. In the example below, the likelihood of Attrition % increases by 11.58x if monthly income goes up. But why is that so? Could it be because for those employees the YearsAtCompany is also more?

Maybe Power BI visual needs to remove outliers.

Power BI visual, currently, doesn’t analyze this for us.

Why are employees leaving if we increase their monthly income?

I want to set this up for my data?

Ok, here are steps to achieve this.

Step 1: Download and Install Power BI Desktop Feb 2019 from here.

Step 2: Enable this visual from “Preview features”.

Step 3: Restart Power BI Desktop. Click on the visual highlighted to put it on the canvas.

Step 4: In the visual data options, drag the field to analyze in “Analyze”, and possible influencers in “Explain by”.

Note: The visual is evaluated on the table level of the field being analyzed. In this case, we are analyzing Attrition, and hence the visual runs at an Employee level. So you may not need aggregations on “Explain by” field. Otherwise, appropriate aggregations are required.

Step 5: In the visual select “Yes” in Attrition value. In your case, select the value you want to analyze.

Step 6: Share analysis with your boss/team/company, and say Thank you to us ūüôā

No code, drag and drop solution to key influencers analysis in Power BI!

Simple, huh?

Thanks

Ranbeer

PS: This visual is currently not supported in Power BI Embedded, Publish to Web and Power BI Mobile scenarios.

Download Power BI report and play with the visual.

AI + Power BI = Wow BI

I’m glad to inform my readers that Microsoft is adding new AI capabilities inside Power BI. And, these are no-code solutions.

Let’s check these 4 new exciting capabilities in detail and in the order of quick wins as per me.

In this post, I will explain uses cases with examples from multiple industries for each of the new capabilities coming in Power BI. This will be followed by a general approach to solve such problems, and then the new AI + Power BI approach to solve such problems.

Capability 1: Key Driver Analysis – or Key Influencer Analysis

Note: Per Microsoft this would be available to all Power BI users.

Suppose you have a dataset of employee attrition which includes details of the employees who are in the company, who left the company along with age, gender, salary, job role, satisfaction, education, years with current manager etc.

Your task is to find factors influencing attrition. Why are employees leaving the company? What segments of employees are leaving?

A general approach for answering such questions would be to use R or Python, fit a model (say using Random Forest algorithm) or use techniques like RFE (Recursive Feature Elimination) to find out top factors affecting our label – Attrition. More details on this general approach and how we did this using R and Power BI is mentioned in detail in our case study here.

With new AI capabilities in Power BI, this would be just a click away. The outcome of the analysis from Power BI would be shown as a kind of “lollipop” chart as shown below.

Image source: Microsoft

Example: When Parental encouragement is true, the probability of a student to plan to attend college increases by 1.8x,

Or, when the employee has spent more than 2 yrs with current manager and his job satisfaction is low then attrition increases by 2.3%

From the screenshot it is not clear how multiple driver analysis can be performed: Ex: When parental encouragement is true and Gender is male Рwhat happens then? 

A contingency matrix would have helped in this case.

Capability 2: Azure Cognitive Capabilities – Sentiment Analysis, Image tagging, object detection in Power BI

Note: Per Microsoft this would be a Power BI Premium capability

You started a campaign on Twitter and would like to analyze your users sentiments – positive/negative.

For a call center company you would like to analyze chat script and identify key items customers are talking about right within your BI reports.

Or, an E-Commerce company would like to detect objects in the images attached with customer reviews, and identify which product/brand is causing negative sentiments or causing pulling “Andon Cord”.

A general approach would be to use Azure Cognitive APIs inside your Power BI report using Power Query (more about this later) using calls such as: Web.Contents(AzureAPICallWithParams).

Another general approach would be to develop and use custom Deep Learning models. A Twitter sentiment analysis (racial vs non-racial tweet) model was developed by us and is hosted in our GitHub repo.

With new AI capabilities in Power BI, this could be just a matter of invoking a function from Power BI ribbon. We do not know yet how this will be invoked by users. But, definitely this will make our BI reports comprehensive and improve decision making.

A snippet of such comprehensive report is attached below.

Image source: Microsoft

When this comes out in preview we will have to see if Microsoft has provided ability to not fire API calls for items already tagged/analyzed – otherwise you will have to pay for every API calls (even for repeats).

Capability 3: Automated Machine Learning models

Note: Per Microsoft this would be a Power BI Premium capability

Imagine in your Power BI report along side Sales Oppty data I provide you a confidence score or probability score against each Oppty data. The Oppty owner can look at this number and decide which Oppty are more likely to be won so he/she can then focus his/her efforts on top highly likely Oppty.

A general approach to add this would be a data scientist developing such models and a developer integrating it inside the Power BI report, and a business analyst consuming the report.

With new AI capability, Microsoft is targeting business analyst so they can build, train, and apply the models right within Power BI service without writing a single line of code. Isn’t that waow?

From the initial screenshots by Microsoft, it looks like this will be part of DataFlows (another new capability, which I will talk about in later posts)

Image source: Microsoft

When this feature is out in preview, we will have to see how easy will it be to do feature engineering – feature selection, normalization, pruning, binning etc. But, this is for sure going to ease out the effort in long term.

Capability 4: Use your existing Azure ML Models in Power BI

Note: Per Microsoft this would be available to all Power BI users.

This capability is more of easing out collaboration between a data scientist and a business analyst.

Typically a data scientist builds models in Azure ML platform and publishes the model as API endpoint. A data analyst or engineer uses that model endpoint to predict outcomes and populate the data inside the BI report. This BI report is then consumed by a business analyst.

In the new AI approach the models developed by data scientist would easily be searching in Power BI, and a new interface would be provided in Power BI to hook to that model and use it in reports.

There are no screenshots for this capability by Microsoft. 

—–

The public preview of these capabilities will be launched towards the end of Nov 2018.

We would evaluate these capabilities and posts about it when they arrive.

What thoughts you have on these capabilities? How are you going to use these capabilities?

Let us know.

Thank you,

Ranbeer Makin

References:

Power BI AI Capability Announcement

Power BI AI Capability Preview Signup Form

Power BI Embedded for Gov clouds

Most of the articles/posts/questions published on community or websites would be on Power BI “Commercial” product. The URL you have seen would be https://app.powerbi.com

This blog post is about “https://app.powerbigov.us” – Power BI URL for US Gov customers. More specifically this blog post is about embedding Power BI assets (Reports, Dashboards, QnA) for US Gov customers.

I would like to highlight certain differences in app registration URL and config URLs when embedding Power BI assets for US Gov clouds.

-> App Registration URL

The app registration URL for commercial cloud and US Gov cloud for Power BI Embedded are different. For:

  1. Commercial Product -> https://dev.powerbi.com/apps
  2. US Gov Product -> https://dev.powerbigov.us/apps

-> When you register your app, the Power BI API name in Azure Portal would look like this:

Commercial Product

commercialproduct

US Gov Product

govproduct

TIP: Based on our experience, when troubleshooting please look out for the API name that you see in Azure Portal. If you are embedding for Gov clouds, the API name should be “Microsoft Power BI Government Community Cloud”. If that is not the name, you would need to register the app on https://dev.powerbigov.us/apps

-> Embedding Config URLs

Commercial Product

commercialproductconfig

US Gov Product

govproductconfig

You would see “resourceUrl”, “apiUrl” and “embedUrlBase” is different in case of US Gov clouds.

That’s it. These are the only changes in configuration and setup required for embedding in Power BI US Gov clouds. Everything else remain the same.

If you are looking for details on embedding with a sample .NET code, please head to our  blog post on baby steps to embed your Power BI report.

Apply the configuration changes as mentioned in this blog post and you would be set to see the Power of embedded analytics for your US Gov clouds.

Questions? Please contact us through our website.

Thank you

Baby steps to embed your Power BI reports

There are three major steps in setting up Power BI Embedded for your Power BI Reports. These steps apply to embed your dashboards or Q&A as well (except for permission settings).

In this blog post we will be setting up Power BI Embedded for ISV or “App owns data” scenarios. The scenario where your users need not have Power BI License to view reports. You embed Power BI Reports in your custom application say, e-commerce site, or health app etc. for your end users.

Here are those three major steps to embed your reports.

Note: Some of the settings differ when you embed for US Gov clouds. Read our brand new post on settings when embedding for US Gov clouds here

1. Register application

2. Set up permissions in Azure Portal

3. Set up sample code to embed Power BI Reports

 

Step 1: Register application

Step by Step guide.

a. Go to https://dev.powerbi.com/apps and register your application. This step is required since Power BI Rest APIs or .NET SDK requires an “application” to connect to Power BI to get token for embedding.

This application is not your custom application (or portal) where the reports will be embedded.

b. Login with your Power BI Account. This is the account where you have Pro or Premium license assigned. This could be yours or a master account (non-human).

c. Add the following setup. You can put any Application Name, but Application Type should be “Native”

d. Select APIs to access. If you only want to “view” reports, select “Read all reports”, “Read all datasets”, and “Create content”. If you want to embed in edit mode, select “Read and write all datasets”, “Read and write all reports”, and “Create content”. We will/can change these in Azure Portal later.

Note: We have seen if you do not select “Create content” permissions, requests to Power BI APIs fail with 403 error.

e. Click on “Register” button. You will receive your client id (or application id as it is called in Azure Portal). Keep it handy

Step 2: Set up permissions in Azure Portal

Let’s log in to Azure Portal using our Power BI account (the account used to register application above).

a. Login to portal.azure.com

b. Navigate to the Azure Active Directory in the left panel and click on App Registrations. If you do not see your app you just created, select “All Apps” instead of “My Apps”

pbiazureappreg.PNG

c. Click on “PBIEmbedApp” and then on Settings and Required permissions

pbiazureclickpermissions.png

d. On the Required permissions, select Power BI Service. Here you can enable/disable any permissions. 

Click on “Save”.

pbiazurepbiservice.PNG

e. After saving you would see “3” delegated permissions for Power BI Service. While Power BI Service is selected, click on “Grant permissions”.

pbiazure3grant.PNG

This would grant permissions to your app.

pbiazuregrant.PNG

You are set to embed your reports now! You would need 3 things to embed your report in your application.

a. Your app’s client id (Remember I had asked you to keep that handy above). If you miss it no worries, go to Azure Portal and grab the “application Id” for your app under Azure Active Directory. This is nothing but your client id.

b. Power BI Report Group ID and Report ID. How do you find out your report’s group id and report id? Navigate to your Power BI report in Power BI portal. Copy the URL

pbiurl.png

Anything after “groups/” but before “/reports” shown above in red box is group_id, and anything after “reports/” but before the last “/” shown above in blue box is report_id. Copy them.

c. Your Power BI username and password. Usually in ISV or App owns data scenarios this is a master account. This means it can be a person’s account like you or me or any other account which nobody (or I must say “no human”) will use.

Step 3: Set up sample code to embed Power BI Reports

Download sample code from Microsoft’s GitHub repo. You will need to use “PowerBIEmbedded_AppOwnsData” project.

Github URL: https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/App%20Owns%20Data

Under: PowerBI-Developer-Samples-master\App Owns Data\PowerBIEmbedded_AppOwnsData

Go to web.config and update the following settings – applicationId, workspaceId, reportId, pbiUsername, pbiPassword.

pbicodesettings.PNG

Your client id is application id and group id is workspaceid.

Run the application in Visual Studio, and you will see your report embedded!

pbiembed.PNG

If you have any questions, feel free to comment on the blog post, or contact us.

Note: Some of the settings differ when you embed for US Gov clouds. Read our brand new post on settings when embedding for US Gov clouds here

Resolved – Request is not a valid SAML 2.0 protocol message – when embedding Power BI Reports with federated authentication

Phew! Finally, we were able to resolve the error “Request is not a valid SAML 2.0” when embedding Power BI Reports with federated authentication. It took us some time but thanks to the wonderful Microsoft support team who worked with us in debugging and isolating the issues.

Our scenario: Enterprise customer with Power BI Premium capacity planning to embed Power BI reports in an internal application using “App Owns Data” approach. There are scenarios why would you embed for enterprises (also called as organizational embedding), and scenarios why would you use “App Owns Data” approach over “User owns Data” approach. More about this in another blog post.

Ok, then why this error? How to solve it?

Why this error:

When you authenticate using master account the request goes to a federated server (in this case customer’s Identity Provider (IdP)), the IdP validates the credentials, sends back SAML assertion and TokenType, the Azure AD .NET libraries check the TokenType and assigns granttype. This granttype and SAML assertion is sent to Azure AD for confirmation.

In our particular case, the PingFederate Identity server was using a TokenType which Azure AD .NET SDK assumed to be of 2.0 and hence tagged granttype as “2.0” (urn:ietf:params:oauth:grant-type:saml2-bearer). But the assertion was not 2.0, it was actually 1.1.

Hence the error – Request is not a valid SAML 2.0 protocol message.

How to solve this error?

There are two ways to solve this error:

  1. Create a cloud account on customer’s tenant which would not be federated (simple solution), example: abc@tenantname.onmicrosoft.com
  2. Create SAML requests manually, fire to your IdP, modify the TokenType in the code and send this request to Azure AD. You will have to bypass using Azure AD libraries and construct your own requests. (complex solution)

We went ahead with solution 1, used this cloud account as our master account and were able to successfully embed the reports in enterprise internal applications.

You will not face this issue if your IdP is ADFS.

Hope this helps,

Until then,

Ranbeer Makin