Microsoft & R Programming Session Materials & Resources Available

Last Thursday night I had the pleasure of speaking with Gregory Kramer and his friends at the Madison, WI Power BI User Group. We took an introductory look at how Microsoft’s acquisition of Revolution Analytics is making serious waves across the Microsoft data platform. We also walked through leveraging R in Power BI and SQL Server 2016.

New to R & Power BI? Start here.

R visuals in Power BI

Continue reading Microsoft & R Programming Session Materials & Resources Available

Download the Power BI Architecture Diagram

Download the latest version of the Power BI Architecture Diagram here!

As a Data Platform Solution Architect for Microsoft, one of my jobs is to help teach my customers what our amazing tools can do and how those tools work. Interest in Power BI is blowing up and I’m seeing most of my customers express huge interest in this awesome tool. To help facilitate the conversation about how Power BI works and how it can help my customers, I put together this diagram.

Also, each text block in the black area to the right includes a link to the documentation on PowerBI.com for the specific component. So if I’m looking at the diagram and I want to gather more information on the Power BI Gateway – Enterprise, just click the text block or point #2. Continue reading Download the Power BI Architecture Diagram

Getting Started with R Visuals in Power BI

Thanks to the December 2015 update released for Power BI, we can now use R to visualize our data in Power BI! Make no mistake, this is huge news and in this blog post I want to walk you through how to use the new R Script Visualization in Power BI and get you started with using R to create your first visualizations.

Read These Top 5 Power BI Tips

Not only can we create and download custom visuals from PowerBI.com to extend the capabilities of Power BI, we can use R to create a ridiculous amount of powerful visualizations. If you can get the data into Power BI, you can use R to perform interesting statistical analysis and create some pretty cool, interactive visuals.

Getting Started

If you’re new to R, like myself, R is a programming language for statistical data analysis. The R programming language is Continue reading Getting Started with R Visuals in Power BI

Sentiment Analysis & Key Phrase Detection w/ Power Query & Power BI

Recently I worked on a neat little POC with Patrick Leblanc for a customer in Education who wished to perform sentiment analysis and key phrase extraction on surveys completed by students regarding classes and instructors, which brings me to this blog post.

Using Azure ML and a free subscription to the Text Analytics API, I’m going to show you how to perform sentiment analysis and key phrase extraction on Continue reading Sentiment Analysis & Key Phrase Detection w/ Power Query & Power BI

Why I Joined Microsoft

new-microsoft-logo-square-largeIf you follow me in social media, you may have seen my announcement that I’ve joined Microsoft. Late in October I resigned my position at Pragmatic Works as a Senior Business Intelligence Consultant and accepted an offer from Microsoft to join their Education Specialty Teams Unit as a Data Platform Solutions Architect. This is such an awesome opportunity and one that I’m so very excited about but I wanted to take a few moments to share my reasons for resigning from Pragmatic Works and joining Microsoft.

This was an incredibly difficult decision that I did not make lightly. I spent over a month thinking, praying, and talking with my wife, Dad, and a few trusted friends about the decision. For the past seven years I’ve loved working, growing, and learning with the wonderful people at Pragmatic Works so I knew any opportunity I would consider would have to be the exact right opportunity. But after all the consideration both my wife and I felt like that this was an opportunity we were led to and that was right for our family at this point and time.

I knew that transitioning from a consultant to a solutions architect position would challenge me and force me to stretch and grow. I felt like that the opportunity at Microsoft would provide me the chance to continue my learning on a different level and this is one of the things that led me to Microsoft.

Also, the information technology field is changing so mind-numbingly fast that its impossible to stay abreast of all the changes, update, and products. Working with Microsoft will provide me the opportunity to learn and work with these new technologies before they’re even released. With Microsoft, I can stay on the bleeding edge of Microsoft’s data platform.

My position at Microsoft also affords me the ability to work from home unless I’m on the road. Time with my family and children is incredibly important to me. Working from home affords me the luxury of eating breakfast, lunch, and dinner with my wife and babies. My kids are growing up and changing so fast and I want to be there for as much of it as possible.

So how will things be changing here at SQLDusty.com? Well, I’m in a brand new role facing an incredible challenge to learn the ins and outs of a bunch of quickly changing technology so you notice that I’m not posting as frequently.

Also, the topics I do post on may increase in variety of topic. Previously I was neck deep in business intelligence (which isn’t a bad thing! BI is awesome!) but now I’ll be working with customers and technologies across the data platform.

I know this is going to be a wonderful journey and learning opportunity and I can’t wait to share what I’m learning with you, my friends and fellow nerds!

 

 

Tons of Updates to Power BI in October!

There were so many updates to Power BI this month I thought I’d put all the links to the information on the updates in one place so we can get caught up quickly on everything that changed with the tool this month. Down below you’ll find my commentary on which updates I’m most excited about and links to the Power BI blog to get all the information on all the changes!

New to Power BI? Start here.

The big one here, in my opinion, is the ability to use custom visuals! Not only can you create your own visualizations to meet your organization’s needs, you can download other custom visualizations that have been shared in the Power BI Visuals Gallery. Some of these custom visuals are just awesome. The capabilities of this tool are off the charts (see what I did there?)!

Continue reading Tons of Updates to Power BI in October!

10 DAX Calculations for your Tabular or Power Pivot Model (Part 2)

This is part two of my 10 DAX Calculations blog series. In this series I’ve blogged ten different DAX calculations you may find useful in your Power Pivot, Tabular or Power BI model. So if you missed part one, I would encourage you to check that out.

Read 10 DAX Calculations for your Tabular or Power Pivot Model (Part 1)

So here’s five more DAX calculations (in no particular order) that I hope you will find useful. Enjoy!

5. DAX Use an Inactive/Custom Relationships in a Calculation

In Tabular and Power Pivot models, you are limited to only one Active relationship between two tables. Often in a relational database you’ll have a role-playing table or a table that is related to another table with more than one foreign-key. A common example of a role-playing table is a Date dimension table since our fact tables often have multiple dates, which is what the following screenshot depicts. We can see that there are two relationships between the Sales and Date tables.

image

The solid line indicates that this is an Active relationship. The dotted line indicates that relationship is Inactive. In the Manage Relationships window, you can clearly see that one of the relationships is Inactive (highlighted in red). What this means for us is that during slicing, dicing and filtering the Active relationship is used.

The good news is that we can still build calculations that leverage Inactive or unspecified relationships in our model! To do this we can use the USERELATIONSHIP function. This function allows us to specify which columns to relate two tables together.

Here’s an example of a calculation for Total Quantity that uses the relationship highlighted in red in the above screenshot:

Total Quantity by Update Date:=CALCULATE([Total Quantity],USERELATIONSHIP(Sales[UpdateDate],'Date'[Datekey]))

 

So when we slice the Total Quantity by Update Date calculation by the Date table, the relationship used is the not the default Active relationship as is the case with the Total Quantity measure. We can clearly see this illustrated below in the pivot table:

image

4. DAX Semi-Additives Measures Opening Period and Closing Period Calculations

Sometimes we have a requirement to create a semi-additive type calculation. If you’re familiar with creating SSAS multidimensional cubes, you’re probably familiar with the concept of semi-additive measure. A semi-additive measure is a measure that is not fully aggregate-able meaning that to find the correct measure amount we cannot aggregate the measure across all time. Consider a measure for account balances or product inventory. If we wish to calculate the current product inventory for the year we must return the inventory on the last day of the year instead of summing the account balances for each day in the year.

There are a couple useful DAX functions we can use to find the opening period balance/inventory or the closing period balance/inventory: FIRSTNONBLANK and LASTNONBLANK.

Here is an example of an opening period type calculation. This calculation will return the first non-blank value in a given date range. Ideally, this will be the product inventory on the first day of the month or year.

Starting Inventory:=CALCULATE([Sum of Inventory], 
FIRSTNONBLANK('Date'[Datekey],[Sum of Inventory]))

 

And here’s a closing period type calculation. This calculation will return the last non-blank value in a given date range.
Closing Inventory:=CALCULATE([Sum of Inventory], 
LASTNONBLANK('Date'[Datekey],[Sum of Inventory]))

 

And here’s a sample of the query results:

image

Now I can easily calculate inventory growth rates!

Inventory Movement:=[Closing Inventory]-[Starting Inventory]

 

Inventory Movement Percentage:=DIVIDE([Inventory Movement],[Starting Inventory])

Pretty cool stuff!

image

3. DAX Previous Year, Previous Month, Previous Quarter Calculations

There’s a series of specific DAX functions that I think you’ll find useful for calculating the measures for a previous period:

PREVIOUSYEAR

PREVIOUSQUARTER

PREVIOUSMONTH

In part 1 we looked briefly how to calculate the previous MTD calculation, but these functions can also just be used to calculate the previous period metrics and compare the previous period to the current period.

Here’s a couple of examples of using PREVIOUSMONTH and PREVIOUSYEAR to calculate the Starting Inventory for the previous periods:

Previous Month Starting Inventory:=CALCULATE([Starting Inventory],PREVIOUSMONTH('Date'[Date]))

 

Previous Year Starting Inventory:=CALCULATE([Starting Inventory],PREVIOUSYEAR('Date'[Date]))

 

In the query results we can now see that we’re able to calculate the previous month and previous year starting inventory amounts. Excellent!

image

2. DAX First Day of Year, Quarter or Month Inventory/Balance Calculations

The previous examples in this post have all been calculations relative to the level of the Calendar Hierarchy being browsed, but sometimes we just need to calculate the measure on the first day of the year, quarter or month no matter what level we’re browsing. For those situations, we can use the following functions:

STARTOFYEAR

STARTOFQUARTER

STARTOFMONTH

Here you can see the calculations for the Year Starting Inventory and Quarter Starting Inventory:

Year Starting Inventory:=CALCULATE([Starting Inventory],STARTOFYEAR('Date'[Date]))

 

Quarter Starting Inventory:=CALCULATE([Starting Inventory],STARTOFQUARTER('Date'[Date]))

 

And now we have the Inventory Amounts for the first day of the year or quarter:

image

1. DAX Rolling Sum and Average Calculations

This type of calculation is easier to set in a multidimensional cube in my opinion but with that said I am more of a cube guy. To get this working, I first created a calculation that sums the total Sales Amount for each day in the past 90 days.

To do this I used the following functions:

DATESBETWEEN

FIRSTDATE

LASTDATE

DATEADD

And here’s the calculation:

Rolling 90 Day Total Sales Amount:
    = CALCULATE([Total Sales Amount], 
        DATESBETWEEN('Date'[Datekey],
            FIRSTDATE( /* FIRSTDATE gets the first date in this date range which will be 90 days ago */
                DATEADD( /* DATEADD lets me navigate back in time */
                    LASTDATE('Date'[Datekey]) /* This returns the last day no matter if I'm at the day, month or year level */
                    ,-89,Day
                )
            ),
            LASTDATE('Date'[Datekey]) /* Use the max date for the end date */
            )
        )

 

Review the comments in the code above to get a better idea of what all the functions are being used for.

Then I created a measure that counts the days that exist within the past 90 days. If the day I’m counting is the first day in my calendar that I have data, I only want to count that one day. This calculation is very similar to the previous calculation except I’m using the COUNTX function to count the rows returned.

Day Count:
    = COUNTX(
        DATESBETWEEN('Date'[Datekey],
            FIRSTDATE(
                DATEADD(
                    LASTDATE('Date'[Datekey])
                    ,-89,Day
                )
            ),
            LASTDATE('Date'[Datekey])
        )
    ,[Total Sales Amount])

 

Now that I have a calculation to get the rolling total sales amount and count the days all I need to do is simply divide the two numbers:

Rolling 90 Day Average Sales Amount:
    =DIVIDE([Rolling 90 Day Total Sales Amount],[Day Count])

 

And here’s the query results:

image

Notice that for January the Day Count measure shows only 31. This is because prior to January there’s not data so the Rolling Average is only considering days where data exists. Also notice that the numbers for March and Q1 match since both periods should have the same amount of sales and the same number of days.

Resources

10 DAX Calculations for your Tabular or Power Pivot Model (Part 1)

Watch this Power Pivot 101 webinar recording

Feedback?

Let me know your thoughts on these calculations! There’s 100 ways to skin a cat so if you have a different or better way to perform some of these calculations I’d love to see your solution! Thanks for reading! 🙂

Data Warehouse Design Challenge: Relating a Temporal Fact Table to a Date Dimension

This past week I ran into an interesting challenge with a client. The data warehouse is capturing testing data for an educational institution. In the screenshot below, you’ll see Continue reading Data Warehouse Design Challenge: Relating a Temporal Fact Table to a Date Dimension

Drill Down with Power BI Visualizations

A couple weeks ago in a recent update to Power BI, an enhancement was added to enable a drill-down action in Power BI. This has been something that customers have been clamoring for but now its finally here!

Not all visualizations can be used to invoke the drill-down action. Here are the visualizations that you can use the drill-down action in Power BI: Continue reading Drill Down with Power BI Visualizations

Power BI Tips, Tricks & Best Practices Webinar Recording & Materials Now Available

image

Thank you to everyone that attended my Power BI webinar last month, September 29th. Sorry its taken me a while to finally make the information available, but my schedule has been crazy lately! The good news is, however, the recording is available! So if you weren’t able to watch the webinar live, you can still catch the recording anytime you like.

View the Power BI webinar recording

Continue reading Power BI Tips, Tricks & Best Practices Webinar Recording & Materials Now Available

Dustin Ryan is a Data Specialist interested in Azure, SQL Server, and Power BI.

%d bloggers like this: