Business Intelligence Blogs

View blogs by industry experts on topics such as SSAS, SSIS, SSRS, Power BI, Performance Tuning, Azure, Big Data and much more! You can also sign up to post your own business intelligence blog.

«October 2015»

Data Warehouse from the Ground Up at SQL Saturday Orlando, FL on Oct. 10th

SQL Saturday #442SQL Saturday #442 is upon us and yours truly will be presenting in Orlando, Florida on October 10th alongside Mitchell Pearson (b|t). The session is scheduled at 10:35 AM and will last until 11:35 AM. I’m very excited to be presenting at SQL Saturday Orlando this year as it’ll be my first presenting this session in person and my first time speaking at SQL Saturday Orlando! If you haven’t registered yet for this event, you need to do that. This event will be top notch!

My session is called Designing a Data Warehouse from the Ground Up. What if you could approach any business process in your organization and quickly design an effective and optimal dimensional model using a standardized step-by-step method? In this session I’ll discuss the steps required to design a unified dimensional model that is optimized for reporting and follows widely accepted best practices. We’ll also discuss how the design of our dimensional model affects a SQL Server Analysis Services solution and how the choices we make during the data warehouse design phase can make or break our SSAS cubes. You may remember that I did this session a while back for Pragmatic Works via webinar. I’ll be doing the same session at SQL Saturday Orlando but on-prem! ;)

So get signed up for this event now! It’s only 11 days away!

Read more

Create Date Dimension with Fiscal and Time

Here are three scripts that create and Date and Time Dimension and can add the fiscal columns too. First run the Dim Date script first to create the DimDate table. Make sure you change the start date and end date on the script to your preference. Then run the add Fiscal Dates scripts to add the fiscal columns. Make sure you alter the Fiscal script to set the date offset amount. The comments in the script will help you with this.

This zip file contains three SQL scripts.

Create Dim Date

Create Dim Time

Add Fiscal Dates

These will create a Date Dimension table and allow you to run the add fiscal script to add the fiscal columns if you desire. The Create Dim Time will create a time dimension with every second of the day for those that need actual time analysis of your data.

Make sure you set the start date and end date in the create dim date script. Set the dateoffset in the fiscal script.

Download the script here:


Read more

Excel Tip #29: Forcing Slicers to Filter Each Other when Using CUBE Functions

As I mentioned in my original post, Exploring Excel 2013 as Microsoft’s BI Client, I will be posting tips regularly about using Excel 2013 and later.  Much of the content will be a result of my daily interactions with business users and other BI devs.  In order to not forget what I learn or discover, I write it down … here.  I hope you too will discover something new you can use.  Enjoy!


You have went to all the trouble to build out a good set of slicers which allow you to “drill” down to details based on selections. In my example, I have created a revenue distribution table using cube formulas such as:

=CUBEVALUE(“ThisWorkbookDataModel”,$B6, Slicer_Date, Slicer_RestaurantName, Slicer_Seat_Number, Slicer_TableNumber)


Each cell with data references all the slicers. When working with pivot tables or pivot charts, the slicers will hide values that have no matching reference. However, since we are using cube formulas the slicers have no ability to cross reference. For example, when I select a date and a table, I expect to see my seat list reduce in size, but it does not. All of my slicers are set up to hide options when data is available. There are two examples below. In the first, you can see that the seats are not filtered. However, this may be expected. In the second example, we filter a seat which should cause the tables to hide values and it does not work as expected either.



As you can see in the second example, we are able to select a seat that is either not related to the selected table or has no data on that date. Neither of these scenarios is user friendly and does not direct our users to see where the data matches.

Solving the Problem with a “Hidden” Pivot Table

To solve this issue, we are going to use a hidden pivot table. In most cases we would add this to a separate worksheet and then hide the sheet from the users. For sake of our example, I am going to put the pivot table in plain sight for the examples.

Step 1: Add a Pivot Table with the Same Connection as the Slicers

In order for this to work, you need to add a pivot table using the same connection you used with the slicers. The value you use in the pivot table, should only be “empty” or have no matches when that is the expected result. You want to make sure that you do not unintentionally filter out slicers when data exists. In my example, I will use the Total Ticket Amount as the value. That will cover my scenario. In most cases, I recommend looking for a count type valu

Read more

SQL Internals Reading Data Records Part 4: Null Bitmap

  • 5 July 2012
  • Author: BradleyBall
  • Number of views: 5151
Hello Dear Reader and welcome back to part 4 on our series on how to read a Data Record.  If you haven’t been reading along here are some links for you.  In Part 1 we covered the Tag Bytes.  In part 2 we covered the Null Bitmap Offset.  And in Part 3 we covered the Fixed Data Portion of a record.  Sorry this one took so long, but as I was working on reading the Null Bitmap something odd happened, I found changes in the Null Bitmap between 2005 and (2008, 2008 R2, and 2012). 

“So Balls”, you say, “What changed?”

Excellent question Dear Reader 2008, 2008 R2, and 2012 are all consistent with one another, but if one does a search on the Null Bitmap and pulls back any of the blogs on them they didn’t match up with what I was finding.  Maybe this changed in a service pack, or it was something simple and under the covers, but there is definitely a difference Dear Reader.  That difference is in the Hex pair that make up the Null Bitmap, but I’ll cover that in another blog that I’ll link back to here. 


First up let’s talk about what we came here for the Null Bitmap.



First let’s update our chart so we know what part of the Data Record we are tackling.  Once again these images come by way of Paul Randal (@PaulRandal | Blog) and the MCM Video series on Data Structures and the good people from Microsoft. 



The Null Bitmap portion of the record actually has two parts.  The first is a two byte value that tells us the number of columns in the record, the second is a one byte value called the Null Bitmap.  And while the name sounds very fancy it is simply what it sounds like, it is a map of the Null and Non Null values in a record stored in bit format.   When we look at the Null Bitmap 0=a column that is in use, and 1=a column that is NULL.


In the Record it is in Hexidecimal format.  All of the records that we look at use two Hex pairs, and each block is 4 bytes in length, so we have 8 Hex characters making up a 4byte block.  A regular data record will always have a Null bitmap, but Records that are formatted using Sparse do not.  Mark S. Rasmussen (@improvedk|Blog) is a very smart fellow that I had the pleasure of doing a lightning talk with at the PASS Summit 2011.  He has written this blog explaining the Null Bitmap is not always present in data records.

So now that we’ve got some extra detail out of the way let’s to examples.  First we’ll create our table with two fixed length columns and three variable length.  We’ll keep the variable length columns as nulls at first so we can see how the Null Bitmap changes.

       DROP TABLE dataRecord2
CREATE TABLE dataRecord2
                     (myID INT
                     ,myfixedData CHAR(4)
                     ,myVarData1 VARCHAR(6)
                     ,myVarData2 VARCHAR(6)
                     ,myVarData3 VARCHAR(6)

INSERT INTO dataRecord2(myID, myfixedData, myVarData1, myVarData2, myVarData3)
VALUES (7, 'XXXX', null, null, null)

Now that we’ve got our table and a record inserted let’s use DBCC IND to find our page.

DBCC IND(demoInternals, 'dataRecord2',  1)

Remember type 10 is an allocation page and we want a data page or a PageType 1, we see that Page 288 is our candidate.  Now let’s use DBCC Page to get page 288, don’t forget to turn on Trace Flag 3604.  I’m only going to copy the relevant bits from our page dump and remember your page numbers may differ.  I’m using SQL 2012 for this output.

DBCC PAGE('demoInternals', 1, 288, 1)


Record Type = PRIMARY_RECORD        Record Attributes =  NULL_BITMAP    Record Size = 15

Memory Dump @0x00000000136EA060

0000000000000000:   10000c00 07000000 58585858 05001c             ........XXXX...


Here in Red, Green, Bold, and Underlined (sorry to anyone who is color blind hence the bold & underlined…), is our portion of the record slated as our Null Bitmap.  0500 is the first two bytes of our record, remember two numbers equal a Hex pair.  Our Pairs are 05 & 00, they are flipped so you would read them as Hex 0x0005, which translates out to 5 and we do have 5 columns.  Don’t forget to use our handy Hex to binary convertor, The last portion of the record is the Null Bitmap itself 1c.  In Hex this works out as 0X1c and converts to binary as 00011100.  In order to read this binary value accurately we flip it and it becomes 0011100


We break this down per column, because we have two columns that are not null three Variable length columns that are null and then the remaining two 0’s are not in use.  So why are they are you may ask?   Because 1 byte equals 8 bits, and these are left over bits.


Now this is one of the differences that I’ve noticed from 2005 to 2008 on up, in 2005 the left over bits where marked as 1’s.  More to follow up on this, but first I want to finish up on our Null Bitmap.  So now Let’s change one of our Variable length columns and watch the Null bitmap change.  We’ won’t go in order because it’ll be a little more interesting to go out of order.  So let’s update column myVarData2 to contain some data and do a DBCC PAGE to get our output.

UPDATE dataRecord2
SET myVarData2='WWWWWW'
DBCC PAGE('demoInternals', 1, 288, 1)

 Record Type = PRIMARY_RECORD        Record Attributes =  NULL_BITMAP VARIABLE_COLUMNS

Record Size = 27                   

Memory Dump @0x000000001276A060


0000000000000000:   30000c00 07000000 58585858 05001402 0015001b  0.......XXXX........

0000000000000014:   00575757 575757                               .WWWWWW


So as you can see from our output we’ve got some changes in our Null Bitmap.  We still have 5 columns as noted in our Hex value 0x0005.  Our bitmap now reads 0X14, let’s translate that to binary and we now get 00010100.  We flip that value to 00101000 and it is ready to be read.



Our first two columns remain 0’s because they are in use, column 3 is still null, column 4 is now a 0 because this is in use, column 5 is 1 because it is still null, and we have 00 for our unused bits.


Now if we update our two variable length columns to be not null and run the whole thing again we should get 0’s across the board.  But I’ll leave that to you Dear Reader to play around with.




So I hear you Dear Reader, What in the name of Twinkies does this have to do with how I manage SQL Server?  There are changes big and small made with every release, sometimes we take for granted that some things work the same way.  The Null Bitmap was added in SQL 2005 as an optimization, see Paul Randal’s blog on that subject here.  When statements are made about how SQL Server is more efficient from one version to the next, this is one of those little reasons.


The Null Bitmap allows the process that reads the data record to know what it needs to read and what it doesn’t.  In our example above, it needs columns 1, 2, and 4.  If it read over 3 and 5 that would be a waste of time.  Yet without that Null Bitmap that is what would happen, it’s not that cut and dry but the Null Bitmap is used in the internal code that reads our data records to determine just that.


Thanks again for stopping by Dear Reader see you next time.





Categories: Analysis Services
Rate this article:
No rating


Other posts by BradleyBall

Please login or register to post comments.