Speaking at #SqlSat501 in Dublin

SQL Saturday Dublin

I was truly surprised to see my session selected for this years SqlSaturday in Dublin.

I have heard through others, that this is a well run SqlSaturday, and I am looking forward to attend, speak and learn. There are a bunch of other great talks (which makes mine look like little league) that I plan on attending, subjects such as Azure Sql Data Warehouse, PowerShell and IoT I am really looking forward to.

Check out the full schedule here, and beware, as it might change over time.

To see all the other SQL Saturdays going on, across the globe, check out this site.

Jump into #PowerBI

tsql2sday150x150This months T-SQL Tuesday is hosted by Jorge Segarra (b|t|l) and the invitation is found following this link.

T-SQL Tuesday was started by Adam Machanic (b|t), and this is the SQL Server community’s monthly blog party, where everyone is invited to write about a single common topic. This time, the topic is PowerBI.

I am hoping this blog post makes it into the summary, by Jorge. Admitted, I am a bit late. I only saw the invitation tweet today, and I was kind of lucky it was on topic, with what I was currently working with.

SSAS Performance Dashboard

My story with this half-baked product (the Dashboard you are about to see), is that I needed some way of tracking performance on a couple of Analysis Services (SSAS) query servers. There are a lot of good posts and talks about how to collect and store performance counters and SSAS logs out there, and I suggest you look into this, this or that, if you need inspiration.

The current data set is about 200K rows, as I am sampling each server every 5th minute.

The reason why I say this is half-baked, is that the querying part of the equation is missing. Currently I am only logging/storing Windows performance counters, and due to release procedures, I have not been able to implement the SSAS eXtended Events that gives us the link, to the queries run at any given time. Windows performance counters by themselves are not that interesting, because we can’t correlate them with specific queries. So we can’t really tell, what makes the servers go bunkers.

By Date

The By Date report is intended to let the end-user browse the data, based on the calendar approach to data. This is to identify peak hours, days etc.

By Server

The By Server report is to let the end-user easily distinguish which work load is related to what server. The rest of the break down is again based on calendar.

Brush

In this example the Brush Chart isn’t really fed the proper kind of data, but I put it in there, to let you see the possibilities with it.  Mark the lower chart to zoom in on the upper chart.

StreamGraph

This is also a very cool visualization, not sure it has any relevance to my data, but it looks awesome!

Final Thoughts

What I really miss for this kind of event based reporting, is a chart type that allows me to have a line for say CPU Utilization and on top of that mark events and their duration, by ie. a broken line chart or similar. Not sure how to correctly describe this, but kind of Gant-style on top of a line chart.

I have been working with PowerBI since it emerged, and I have been challenged to keep up with all the features and changes the PowerBI team has released during the last year. I am really looking forward to see what will be served the next year, even more so, because I will be spending more time with PowerBI now than before.

A Hello World Custom Assembly in SSAS

This is my second post i a series of entry-level posts, as suggested by Tim Ford (b|l|t) in this challenge.
I have not set any scope for the topics of my, at least, twelve (12) posts in this new blog category of mine, but I can assure, it’ll be focused on SQL Server stuff. This one is going to be about how to extend Analysis Services (SSAS) with your own custom code.

The example in this post will be the well known Hello World example in the context of SSAS, and I trust this will illustrate the possibilities with this technique well enough, for you to apply your own solution, to your challenges.

Creating the Custom Code

First of all, we have to create the custom code. This can be done with the free tool Visual Studio (download). To get going, we create a new project  [Ctrl]+[Shift]+[N] or via the dialog below:

New Project Dialog

In the next dialog, we then select both which programming language to use for the project and also what kind of output the compiler will provide. I select a Class Library output, programmed in Visual C#, in this example. This will provide us with an assembly, which we can import directly into the SSAS Server.

Class Library Dialog

First a couple of house keeping routines. Even though this is just a tiny example, there’s no need to not do the right thing. Naming conventions should be agreed on, before diving into the code.
We begin by renaming the entire solution:

Rename Solution

I name this one ‘CustomAssembly’

Next we rename the project:

Rename Project

Finally we need to rename the Class File:

Rename Class FileI have named mine HelloWorld.cs. With this in order, we are now ready to implement our custom code.
Of course the code in this example is simple, but I trust you will be able to spot the potential of the technique.

The Class implementation looks as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CustomAssembly
{
    public static class HelloWorld
    {
        public static string GetValue()
        {
            return "Hello World";
        }
    }
}

As I said, very simple. This function only returns the same text, for every call.
In order for us to leverage this via SSAS, we need an assembly to register. We now just need to successfully build the project in Visual Studio and we are off.

Right click the Solution name in the top of the Solution Explorer ([Ctrl]+[Alt]+[L]) or press [Ctrl]+[Shift]+[B] to build.

Build SolutionThis will produce the desired output and put it in a predefined location. Right click the Project and select ‘Open Folder in File Explorer’

Open Folder in File Explorer

In the bin folder, depending on your deployment settings (Debug/Release), you will find your assembly. Remember the location or move it to a known location. Issues can occur, if you register the assembly from the same location as you build.

Registering the Assembly with SSAS

We begin by opening SQL Server Management Studio (SSMS) and connect to the server we want to test our custom code on. When connected, we can right click the Assembly collection and select to add a new Assembly.

Add New AssemblyThis opens a new dialog, in which we can specify different settings, most importantly the settings on security and impersonation. For details on this, please see this MSDN description. The different levels of permission settings:

Permission Setting Description
Safe Provides internal computation permission. This permission bucket does not assign permissions to access any of the protected resources in the .NET Framework. This is the default permission bucket for an assembly if none is specified with the PermissionSet property.
ExternalAccess Provides the same access as the Safe setting, with the additional ability to access external system resources. This permission bucket does not offer security guarantees (although it is possible to secure this scenario), but it does give reliability guarantees.
Unsafe Provides no restrictions. No security or reliability guarantees can be made for managed code running under this permission set. Any permission, even a custom permission included by the administrator, is granted to code running at this level of trust.

In my example, I will not have a dedicated account, which I would highly recommend, if you were to go into production with this.

I have selected the path where Visual Studio is configured to put the output, and I have selected Permission Setting Safe and I am impersonating the Current User.

Register Assembly Dialog

When we click OK, the dialog will close, and the collection of assemblies ion the instance will be updated, to contain our newly created custom assembly.

Assembly Registered

Run the Query

The above steps enables us to query the function created, directly from MDX as shown in the screenshot below:

Result Set

Note! The Assembly Name applied in the registration, is also the name I use in the MDX query. Had I named the Assembly MyFirstCode, the MDX would look like this:
My First CodeThink of this as an alias for the Class, the method name does not change.

Next steps

As described above, we can extend Analysis Services with all kinds of thinkable custom code. We can even send back parameters, in order to have some sort of context for the algorithm in question. We can of course also have multiple algorithms per assembly, allowing us to select specific ones, for each specific MDX query.

An assembly can, as shown above, be registered at the server level. But we can also register our assembly in the private assembly collection of any number of databases on the server. This allows us to differentiate the code base, based on the solution at hand.

Now, I am not saying custom assemblies are the solution to all of our challenges on the platform, but in the course of my career I have implemented a couple of solutions where I have used this technique. The end result was far more scalable, robust and better performing than the equivalent MDX voodoo it was set to replace.

 

Permission Scope in Analysis Services

This is my first post i a series of entry-level posts, as suggested by Tim Ford (b|l|t) in this challenge.
I have not set any scope for the topics of my, at least, twelve (12) posts in this new blog category of mine, but I can assure, it’ll be focused on SQL Server stuff. This one is going to be about permission scope in Analysis Services (SSAS).

What this post will not be about: The how to setup basic dimension security in SSAS nor How do you manage Security.

In this post, I will highlight the difference between standard NTFS permission scope and the way SSAS handles Allowed and Denied sets when dealing with multiple roles. So if you define multiple roles on your solution, you should be on the lookout, because SSAS has some surprises.

NTFS

In NTFS, permissions are defined so that deny generally takes precedence over allow. As illustrated in below diagram, we can define an Allowed set as a sub set of the total set. The blue rectangle is to be seen as the full set.

NTFS Allowed SetAnd as we apply a Denied set, this will restrict the previous Allowed sub set, the intersection of the two sets, illustrated below: (The color indicates the finally allowed set.)

NTFS Denied Set

 SSAS

In SSAS however, the Allowed set takes precedence over Denied. So if you apply your usual NTFS logic to your dimensional security in SSAS, you may well be in for a surprise.

When no security is defined in a cube, everything is accessible to everyone. This color indicates the allowed set. (the complete rectangle)

Entire Cube Space

As soon as you introduce the first role, the cube is locked down to everyone not a member of said role.

Role w/ Allowed Set Introduced

If you then introduce restrictions in another role, you will get a different result than in the NTFS based security. The members of the role will still be able to see the full set of the Allowed set. Even though we just Denied that!

Role w/ Denied Set Introduced

Example

By creating two test roles, we can easily bring forward the, to some extend, unexpected behavior of SSAS.

Allowed Set Defined
Allowed Set Defined

As seen in Role Test 1, I have defined the Allowed set to contain Weeks 41 and 42 of the Year 2015. By browsing the Cube through SQL Server Management Studio, we can identify the Allowed set is working:

Allowed OK
Allowed OK

As I the introduce a new Role Test 2, and in that denying the week 42 of 2015, I would expect the browsing result to be only displaying only Week 41, but…

Denied Set
Denied Set

The result we get, when browsing the cube using both roles, shows all dates with data: (WTF! – Yes, you said it!)

Denied Set actually allowing everything?
Denied Set actually allowing everything!?

Fix

Clearly that was not the intention, by denying Week 42. So, how to fix the above violation to the Allowed set?

By adding an empty Allowed set ‘{}’ to the role containing the Denied set, in this case Test 2, as depicted below:

With this Empty Set ‘{}’ in place, we can browse the Allowed set again, but the Denied set does not restrict the result set.

Allow-Denied-Meh

Final Thoughts

While the way SSAS interprets the Allowed and Denied Sets may be straight forward, for simple security tasks. I think the above examples shows just how much testing one needs to do, in order to be totally sure the desired permissions are reflected in the end user experience.

As a side note, adding an empty set to the Denied Set of the first Role (Test1) does not alter the outcome.

 

The Circle of Work Life

Before my now roughly two and a half years in Maersk Line IT, I was working both as a consultant and an internal developer in Rehfeld Partners, now part of IMS Health. At Rehfeld I was both part of the Effektor team, but also worked in the Health Care team as well as the Private Sector team. Before joining Rehfeld, I had a short stop at KMD, which I will gracefully skip describing here. But, about Eight (8) years ago, I left Knowledge Cube where I had been scooped up as a Business Intelligence Rookie. Initially the Company (A-Ware) had three (3) partners, of whom two stayed on to become partners in Knowledge Cube. One of these partners, Erik Svensen (b|l|t), is now Owner of the Company CatManSolution. Erik was one of the initial three who instilled BI into my career path, and now he will, once more.

From today, I will (again) be working with the team on CatManSolution as a Business Intelligence Architect (effectively: BI Dude, so no change there). I am looking so much forward to taking on this opportunity, as I see a lot of fun and challenging tasks ahead – with great people around me. Not to mention a lot of potential for growth and research & development. I will, going forward, be working with the full suite of SQL Server as well as Azure offerings. I have missed out on that, during my tenure at Maersk, so It’ll be good again to get hands-on, rather than just reading up on new features and products.

CatManSolution allows you, as end user, to find report groups and concepts, such as

  • Status and ranking
  • Focus on development
  • Benchmarks and potentials
  • Promotion management
  • Zero sale and distribution
  • Price analyzer
  • New launchings
  • StorePictures and StoreEvent
  • Stock analysis

Data is coming in from an number of different sources, and obviously more sources are to come.