Monday, February 27, 2017

Tutorial On Creating A Frequency Distribution Chart With Microsoft Excel, R and Python

I got to join this amazing community of Data Scientists in Nigeria. We are a mix of experts and beginners. Today, I created a tutorial for the beginners to see how to do a common task like frequency distribution plot in both Python and R, also decided to include my dearest Microsoft Excel as a control.

The sample data is a fictionalized data for Dominos Pizza Nigeria. One day sales data for their Lekki branch. You can download the practice along raw data file here: https://dl.dropboxusercontent.com/u/28140414/Dominos%20Pizza.csv 


So the business question we want to tackle is: Is there a pattern in the quantities each customer buys? To be more specific, we want to examine the frequency distribution of the quantities purchased per sales transaction.

In Excel, it is extremely straightforward. Just plot a histogram on the quantity field.


Now let's head to doing same with R

I use R 3.3.2 and RStudio.

First, I import the csv file into RStudio.




Though not necessary for what we want to do, but I like doing it for any data I bring into R, I run the summary command on the dataframe/table. > summary(Dominos_Pizza)


Again, not a required step. I check out the standard plot graph on the Quantity field. > plot(Dominos_Pizza$Quantity)


Finally, I do the histogram chart on the Quantity field. > hist(Dominos_Pizza$Quantity)



For now I don't bother customizing the graph elements (labels, color, title, etc.)

It is Python time.

I use Rodeo IDE and Anaconda. 


I import Pandas and use it to read in the csv file. 




And here is the plot graph, like we did in R.


Finally, I create the histogram.



I will try to follow up with more tutorials of complex tasks, and some that are best suited to R and others that are best suited to Python. As per Excel, it is in a completely different class. It is a spreadsheet application. 

Got any particular task you will like me to create a tutorial around? Ask away!

Wednesday, February 1, 2017

Setting Up Power BI Embedded on Microsoft Dynamics NAV 2017

We got a request from a big company to show them how to integrate Power BI with Microsoft Dynamics NAV 2017. 

In other to prepare demo content for the training, I had to install Microsoft Dynamics NAV 2017 and set it up with Power BI. NAV 2017 can integrate with Power BI via four doors -- Power BI Embedded, Power BI service NAV content pack, Power BI Desktop OData and SQL connection to the NAV database. The Power BI Embedded one is more of you bringing in your Power BI dashboard (any one, not necessarily one built from NAV datasets) into NAV reports.

I made sure to take a lot of screenshots along the way. I know this won't be interesting to a lot of us, but for the few who some day will stumble on this when they are stuck getting to make all the frustratingly many moving parts work in sync, this can be a time/life saver.

First, what is Power BI Embedded?

It is when you make your Power BI reports show in another application. Like I did to make my stock analysis dashboard show up on my Nigerian Elite web app. So I embedded it there. And the new NAV 2017 also comes with that ability for you to embed your Power BI dashboards in its reports page.



So below are the visual steps to setting Power BI embedded up in NAV 2017.

In the beginning, there was no Power BI Reports, just a link to setting it up.



Then I followed the setup instructions.



At this stage, I had to go to Microsoft Azure on the account that is the O365 administrator and has Power BI pro enabled. Under Azure Active Directory, I created a new App Registration.






Copied the sign-on URL from the NAV reply URL (in the setup dialog box). Ignore the 8080 showing up in mine, it was the result of following a wrong instruction online, I had to verbatim copy the Reply URL value here before I could get it to work.



Got the App Id and Key.




Set the Permissions and add Power BI service (enabled all the delegate permissions for Power BI service).





Continued the setup on NAV 2017.




Now it was half time.  I was half done.

Then continued.

I got a new dialogbox asking me to authorize azure services to connect to Power BI services.




On clicking on the link, I had to login again.





All set! I can now embed any of my many Power BI reports.

:)