Archive

Archive for the ‘Uncategorized’ Category

Quickly Retrieving the Row Count for All Tables in a SQL Database

March 23rd, 2012 No comments

A quick post that proved helpful to me today. I needed to see the number of rows for all tables in the database. I found this query:

SELECT ‘[' + SCHEMA_NAME(t.schema_id) + '].[' + t.name + ']‘ AS fulltable_name, SCHEMA_NAME(t.schema_id) AS schema_name, t.name AS table_name,
i.rows
FROM sys.tables AS t INNER JOIN
sys.sysindexes AS i ON t.object_id = i.id AND i.indid < 2

on Brian Knights blog: Quickly Retrieving the Row Count for All Tables. One thing to note is that the numbers could be a little out of date. DBCC UPDATEUSAGE (DBNAME) should resolve that, the problem is that this only works when you are admin. If you want to be 100% accurate you might need to do a little more investigation.

Categories: Uncategorized Tags:

Online session: Building the Perfect Tabular BI Semantic Model for Power View

March 11th, 2012 No comments
Categories: Uncategorized Tags:

SQL Server 2012 launched !

March 6th, 2012 2 comments

As of today you can download a evaluation version SQL Server 2012.  For purchasing SQL Server 2012 you have to wait until April first. For more information check out the official blog post: SQL Server 2012 Released

This is the first SQL Server release I am proud to be part of, the AS team has delivered tons of new features in the BISM, tabular projects, Power View integration, more DAX and of course a new version of the PowerPivot add-in. I think this is great release for BI with Power View now added to the stack as great interactive data exploration, visualization, and presentation experience.

This release also includes the long awaited 64 bits version of the Data mining add-in, which you can download here.

PowerPivot for SQL Server 2012 is now here as well, you can download it here.

Categories: Uncategorized Tags:

What is using all that memory on my Analysis server instance ?

February 25th, 2012 6 comments

With the release of SQL Server 2012 tabular models identifying what the memory use of objects on your server instance is has become more important then ever. Since everything is in memory, being able to tune the model to remove columns that take up loads of memory could be very valuable. Or being able to use your development database to extrapolate the memory usage that you will have on you product machine.

I have created a PowerPivot workbook that will allow you to investigate the memory usage on your server instance (this report could also be used on a MOLAP instance).

The report contains two worksheets. Worksheet 1 contains two dashboards, the first dashboard contains the top 10 tables on the server instance by memory usage.

The second worksheet allows a more detailed investigation on all the objects on the server by using a pivottable. I have created a hierarchy of all the objects that allows to start at the top to bottom when you want to investigate the details.

of course since this is a pivottable there you can create your own insights if you want:

 

You can download the workbook and try for you self here BISMServerMemoryReport.

In order to get this working on your tabular or multidimensional server is change the connection:

After this, refresh the table and refresh the data in the workbooks from Excel.

The data itself is being retrieved into one table by a DMV function:

Then the data that came in was manipulated by several DAX calculated columns using new SQL 2012 DAX functions like parent child functions and created hierarchies for them.

I hope you can use this workbook, let me know if you have any comments or feedback on the report. I am always looking for new insights and ways to improve the workbook.

Categories: Uncategorized Tags:

Whitepaper and Samples Released: Data Analysis Expressions (DAX) In the Tabular BI Semantic Model

January 4th, 2012 2 comments

An updated version of the whitepaper “Data Analysis Expressions (DAX) In the Tabular BI Semantic Model” is available for download at http://go.microsoft.com/fwlink/?LinkID=237472&clcid=0×409.

The Whitepaper is now updated with SQL Server 2012 DAX functions and well worth the read if you are interested in DAX (which you no doubt are if you are following my blog). Thanks to Peter Meyers and Howie Dickerman for writing this whitepaper and Owen Duncan for contributing to it.

Categories: Uncategorized Tags:

Why do I blog

January 3rd, 2012 No comments

ok ok, I am much to late to the party for #meme15 by Jason Strate

From the post by Jason:

#meme15 is dedicated to discussing and sharing tips and tricks for blogging and using social media.  This can be from a personal or professional standpoint.  The intent is that through these posts by myself and others will provide some insight into how to succeed in these areas.

This month’s writing assignment was:

  • Why did I start blogging?
  • Why do I currently blog?

I was reading the excellent blog post by Jen Stirrup that sparked me to share my experiences as well.

Why did I start blogging?

I started blogging on November 1st 2007 to share the things I found on the internet with colleagues, customers and myself :) At the time  I was working as a consultant and I visited customers who were not as much into blogs and the internet as I was. This gave me the opportunity to share what I found, but at this point it was just aggregating other blogs.

Around 2009 I started writing a little bit more substantial blog post with the CTP release of Project Gemini now known as PowerPivot, PowerPivot really changed my enthusiasm to a whole new level. From this post on I started doing more substantial blog posts to share about my experiences on Gemini, this also was my way into the product team (Through Rob Collie and his blog PowerPivotPro.com) that helped me when I got stuck on Gemini. After a while blogging and twitter got me into the online community and I started doing presentations on SQLSaturday and other events. And eventually it led me across the pond to the us to work for ms.

Why do I currently blog?

Since I started to work for Microsoft my blogging situation changed quiet a bit, but I still love blogging. Why do I keep on blogging?

  • Since i now have the latest information, i can share it the moment the product gets out
  • I really like my ask a questions page, it gives me a good idea what you all are doing with powepivot and it gives me ideas on what to blog about.
  • It allows me to test out the product with some real world scenarios
  • Gives me ideas for presentations
  • It keeps me connected to the twitter and blogging community. I really like the community but sometimes it’s really hard to stay connected to the world outside Microsoft.
Categories: Uncategorized Tags:

PowerPivot: Calculate ratio to parent

January 3rd, 2012 1 comment

With SQL 2012 PowerPivot we have hierarchies at our disposal, one of the most common calculations we want to do with those hierarchies is doing a ratio to parent. This blog describes how you to do that.

I started with two simple tables, one a team / chapter table, the other sales by chapter:

Now I loaded these into PowerPivot, created a reletionship and a hierarchy:

Next I use the Hierarchy in a pivottable together with a Sum of SalesAmount measure:

Now we need a new measure that allows us to compare the actual sales per chapter with the sales of the team (or of all the chapters of the same team). This is a pretty  straightforward DAX formula once you understand my second phrase “ all the chapters of the same team”. What we in DAX can do is overwrite filtercontext and that is what we can do here.

If you take the same pivottable again but now we look at the highlighted cell:

What filters are used to calculate the sum of sales?  The filters here are “Hierarchy1 = Team” and “Hierarchy2=chapter1″. Now using calculate we can overwrite filters, so all we need to make sure of is that in our new measure we never listen to the Hierarchy2 filter, or in the DAX case we always filter Hierarchy2 by ALL values in the column. The reason that we can use ALL values in the Hierarchy2 column is that the other filter is still in place, Hierarchy1 is still filtered by “Team” so it will only return values for chapters that belong to the “Team”

This gives us the following DAX statement:

=CALCULATE([Sum of Sales],ALL(Table1[Hierarchy2]))

Gives us the following pivottable:

Now it is pretty simple to add a ratio formula:

=[Sum of Sales] / [Sum of sales all chapters]

That gives us the result we want:

So that turned out to be pretty easy once you understand the concept.

But what if you have multiple levels ? This needs a little more extended “Sum of Parent” formula since we need to override all level individually:

=if(HASONEVALUE(Table1[Hierarchy2]),
                    CALCULATE([Sum of Sales],all(Table1[Hierarchy2])) ,
                    CALCULATE([Sum of Sales],all(Table1[Hierarchy12]))
     )

Here we check if we are actually at the lowest level of the hierarchy “Table1[Hierarchy2]” if that is the case we override the filtercontext with that level. Otherwhise we override with the level above. This can be repeated if you have more levels:

 

Categories: Uncategorized Tags:

PowerPivot and Excel: Using a dynamic label in a chart

December 29th, 2011 12 comments

I got this interesting question on my ask a questions page that I would like to answer by writing a blog post.

The question was the following:

I have a table fetched from a SQL database that contains a few fields but the interested ones are ComputerID and SystemStartupTime which is the time a computer takes to boot.
I have been asked to display this information on a graph averaged by the average of each ComputerID which I did like this:
myWonderfulMeasure:=ROUND(AVERAGEX(SUMMARIZE(myTable,myTable[ComputerID],”AveragePerComputer”,AVERAGE([SystemStartupTime])),[AveragePerComputer]), 0)
The graph using this measure shows those values by Year and WeekNumber successfully using slicers to play with different variables.

Now I have to display this average on another graph by segments of 30 seconds. This means, by number of machines that booted in:
- 0 to 30 seconds
- 31 to 60 seconds
- …

I wanted to use an autocalculated column. However I lose the average per computer (as the table lists all of the boot times).
I then tried to create a new measure with a long and dirty IF:
=if(Table[myWonderfulMeasure]<=30, “0-30″, if(Table[myWonderfulMeasure]<=60, “30-60″, [..] ))
However it doesn’t work at all. I can only use this measure as value (which displays nothing on the graph except 0, 0.1, .., 0.9, 1 on the y axe, and no bar) I can’t put the measure on the Legend Field for instance.

Unfortunately it is not possible to use a measure and put it on a label in Excel (but it is possible in Power View for non text meaures). So we need another solution. We can solve this in the exact opposite way. Lets look at an example using adventureworks with the FactInternetSales and DimProduct (filtered to only contain the current items) table:

I want to see the number of products per color per salesgroup where salesgroup is defined in Large, Medium and Small. The first idea that comes to mind is to create a measure that does what we want. That is pretty straightforward but unfortunately doesn’t work in Excel. So we need to come up with another solution.

What I did is define a table in Excel that defines the SalesGroup with Labels and min and max values:

Now I load this into PowerPivot as a linked table (no relationships created) and start by creating a pivottable using Color and the Label

Now I can create a measure that determines the number of products that fall between the min and max for each SalesGroup:

=if(HASONEVALUE(Categorygroup[Label]),
		COUNTROWS(
			FILTER(DimProduct,
				[Sum of SalesAmount] >= VALUES(Categorygroup[Low])
				&& [Sum of SalesAmount] < VALUES(Categorygroup[High])
				)
			)
	, COUNTROWS(DimProduct))

This gives us the result we wanted:

or create a chart from it:

Lets look at this measure step by step:

  1. if(HASONEVALUE(categorygroup [Label]), … , COUNTROWS(DimProduct)): Do we have a single categorygroup selected in the pivottable ? If yes we can select a range, if more are selected return COUNTROWS(DimProduct)
  2. COUNTROWS(: Count the number of rows
  3. FILTER(DimProduct,  : From a filtered DimProducttable (observe that the filter created by putting colors on rows in effect as well)
  4. [Sum of SalesAmount] >= values(categorygroup [Low])
    && [Sum of SalesAmount] < VALUES(categorygroup [High])) : Filter all rows in the DimProduct table where a measure [Sum of SalesAmount] is greater or equal then the value of categorygroup [Low] for the current categorygroup (using VALUES) and [Sum of SalesAmount] smaller then the value of categorygroup [High]

Hope this showed a simple approach to create a solution for Excel that gives you dynamic labels.

Categories: Uncategorized Tags: