Friday, October 5, 2012

How to group many role playing time dimensions in one time dimension?

Just set the Visible property of all time dimensions to False, add a new time dimension, and replace all measures by calculated measures. Each calculated measure should use the LINKMEMBER function in order to use the visible time dimension instead of the other hidden time dimensions.

Below an example of a calculated measure: 


([Measures].[MyMeasure], LINKMEMBER([Date].[Year].CURRENTMEMBER, [Date Hidden].[Year]), LINKMEMBER([Date].[Date].CURRENTMEMBER, [Date Hidden].[Date]), LINKMEMBER([Date].[Week].CURRENTMEMBER, [Date Hidden].[Week]), LINKMEMBER([Date].[Month].CURRENTMEMBER, [Date Hidden].[Month]), LINKMEMBER([Date].[Calendar].CURRENTMEMBER, [Date Hidden].[Calendar]))

Sunday, September 23, 2012

Powershell script that checks a folder for new files to process by a SSIS package

Using the script below, everytime a new file is deposited in the folder "MyFolder", the powershell script detects that and starts the execution of a SSIS package.

$folder = 'D:\...\MyFolder'
$filter = '*.*'
$cmd = '
DTExec /FILE D:\....\Package.dtsx'
$fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{
 IncludeSubdirectories = $false
 NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'
}
$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action {
 invoke-expression -command $cmd
}

Saturday, August 25, 2012

Why SELECT COUNT(*) returns 1?


I think that there is no answer to the question; it’s just a specific behavior of SQL Server.

Tuesday, August 14, 2012

Russian population projection for 300 years

Yippee! This is my second post, and as I care a lot about my descendants, I think that it’s important to know if after centuries some countries will be crowded with people, and if my descendants will have a place to live on earth and especially in Russia, that why I chose to write an article about Russian population projection for 300 years. 

I didn't have a chance to live in Russia, and to see the Kremlin, but I think that some of my descendants will live there, that why I chose Russia for this article :)


To do the projection, I used the data mining engine that is encompassed in SQL Server Analysis Services, I used the Time Series algorithm to do the forecasting.


To train the data mining model, I used only some few data that I listed below, I know that is not enough in order to have accurate results, but I didn’t find raw data that are ready to use (like a csv file).

Russian population:
1965 - 126.74 Million
1970 - 130.40 Million
1975 - 134.20 Million
1980 - 139.01 Million
1985 - 143.85 Million
1990 - 148.29 Million
1995 - 148.14 Million
2000 - 146.30 Million
2005 - 143.15 Million
2010 - 141.92 Million

As result, in 2314 the Russia population will be 225 Million, this is a good news, for such a big country like Russia, a population of 225 Millions is acceptable. 

This is just an article that could help some developers to use the Time Series algorithm, I'm sure that after 300 years the Russian population will not be 225 Millions, because I didn't take in consideration external factors like climate changes, economy,...

Here you can find the DMX script that I used BI4Fun_RussiaPopulationForecasting.dmx, and below a screenshot of the output I got in SSMS.


Sunday, August 12, 2012

Whack-a-Rabbit game using SSRS :)

This is my first post, and I chose to show you a simple funny game that I recently developed using SSRS 2012. (for people who don't know, SSRS is Sql Server Reporting Services).

I smile each time I play that game, because it was developed using a tool that is not designed to create games!
The game rules are simple; the player needs to whack the rabbit each time he appears in a hole, if the player doesn't succeed to whack it on time, then the page will refresh each second and the rabbit will appear in another hole, and if he whacks him, then the score will increase by one.
In the video below you can see me in action playing that game.


You can play the game on your machine, here the link to the rdl file BI4Fun_WhackARabbit.rdl, and if you have some suggestions, don't hesitate to leave them as a comment!