MSB I Cheat Sheet
MSB I Cheat Sheet
MSB I Cheat Sheet
Expression
Multiple condition
if statement
Remove a given
character from a
string (ex. Remove
"-" from a social
security number)
Script Transform in the Data Flow Task with the code as follows (VB 2008):
Imports System.Text.RegularExpressions
Public Overrides Sub Input()_ProcessInputRows(ByVal Row As Input()Buffer)
Remove any nonnumeric data from
a column
Convert text to
proper case
(ex. 1st letter in
each word is
uppercase)
Round to the
nearest two
decimal mark
Solutions
Solution: Configure the Foreach Loop to loop over any particular directory of
files. The loop should be configured to output to a given variable. Map the
given variable to a connection manager by using expressions.
Conditionally
executing tasks
Pass in variables
when scheduling
or running a
package
Solution: Use the /SET command in the DTExec command line or change the
Property tab in the Package Execution Utility to have the property path like:
\Package.Variables[User::VariableName].Properties[Value]
Loop over an
array of data in a
table & perform
a set of tasks for
each row
Solution: Set the File System task to rename the file and point to the directory
you'd like to move the file to. This enables you to rename and move the file in
the same step.
Solution: Have the 1st Execute SQL Task retrieve a date from a control table of
when the target table was last loaded and place that into a variable. In the Data
Flow Task, create a date range on your query using the variable. Then, update
the control table using a 2nd Execute SQL Task to specify when the table was
last updated.
Solution: Use the lookup Transform or Merge Join to detemine if the row exists
on the destination and ignore a failed match. If the row yields blank on the key,
then you know the row should be inserted into the target (by Conditional Split).
Otherwise, the row is a duplicate or an update. Determine if the row is an
update by comparing the source value to the target value in the Conditional
Split. The update can be done by an OLE DB Command Transform or by loading
the data into a staging table.
Script Transform in the Data Flow Task with the code as follows (VB 2008):
Imports System.Text.RegularExpressions
Public Overrides Sub Input()_ProcessInputRows(ByVal Row As Input()Buffer)
Remove any nonnumeric data
from a column
Convert text to
proper case
(ex. 1st letter in
each word is
uppercase)
[User::DateTimeVar]),2) + "'"
Calculate
beginning of the
previous month
Round to the
nearest two
decimal mark
Calculation Expression
Simple Gross
Profit Calculation
Year to Date
Sales (Works for
any level of Date
Hiearchy)
Aggregate(
PeriodsToDate( [Date].[Calendar Hierarchy].[Year],
[Date].[Calendar Hierarchy].CurrentMember ),
([Measures].[Sales]))
Alternate Year To
Date Expression
(YTD, QTD, MTD)
AGGREGATE (
YTD ([Date Order].[Calendar].CurrentMember),
Measures.[Sales Amount])
Product Ranking
Sales in the
Previous Period
Top 10 Selling
Products (Named
Set)
Three Years
Average Sales
From NOW()
Avg(
{ParallelPeriod( [Date].[Date].[Year], 3,
StrToMember("[Date].[Date].&[" + Format(now(), "yyyyMMdd") + "]")) :
StrToMember("[Date].[Date].&[" + Format(now(), "yyyyMMdd") + "]")} ,
[Measures].[Sales Count])
Drillthrough
Action Caption
Change SSAS
Calculation Text
color
Changing a
Calculation with
a SCOPE
statement
Clear Ration
Value when at all
level
Case
When IsEmpty
(ParallelPeriod
([Date Order].[Fiscal].[Fiscal Year],
1,[Date Order].[Fiscal].CurrentMember))
Then [Measures].[Sales Amount]
Else 1.10 *
([Measures].[Sales Amount],
ParallelPeriod([Date Order].[Fiscal].[Fiscal Year],
1,[Date Order].[Fiscal].CurrentMember))
End
Case
When KpiValue( "Sales Revenue YTD" ) / KpiGoal( "Sales RevenueYTD" ) > 1
Then 1
When KpiValue( "Sales Revenue YTD" ) / KpiGoal( "Sales Revenue YTD" ) <= 1
And
KpiValue( "Sales Revenue YTD" ) / KpiGoal( "Sales Revenue YTD" ) >=
.85
Then 0
Else -1
End
Case
When IsEmpty
(ParallelPeriod
([Date Order].[Fiscal].[Fiscal Year],
1,[Date Order].[Fiscal].CurrentMember))
Then 0
When VBA!Abs
((KpiValue( "Sales Revenue YTD" )- (KpiValue( "Sales Revenue YTD" ),
ParallelPeriod( [Date Order].[Fiscal].[Fiscal Year],
1, [Date Order].[Fiscal].CurrentMember)))
/(KpiValue( "Sales Revenue YTD" ),
ParallelPeriod
( [Date Order].[Fiscal].[Fiscal Year],
1,[Date Order].[Fiscal].CurrentMember))) <=.02
Then 0
When (KpiValue( "Sales Revenue YTD" )- (KpiValue( "Sales Revenue YTD" ),
ParallelPeriod
( [Date Order].[Fiscal].[Fiscal Year], 1,
[Date Order].[Fiscal].CurrentMember)))
/(KpiValue( "Sales Revenue YTD" ),
ParallelPeriod( [Date Order].[Fiscal].[Fiscal Year],1,[Date
Order].[Fiscal].CurrentMember)) >.02
Then 1
Else -1
End
Expression
=DateAdd("d",DatePart(DateInterval.DayOfYear,Today,0,0)+1,Today)
Expression Output Example: 1/1/2010 12:00:00 AM
Uppercase fields
=iif(Fields!DenominatorField.Value = 0, 0,
Fields!NumeratorField.Value/
iif(Fields!DenominatorField.Value = 0, 1, Fields!
DenominatorField.Value))
security number)
Solutions
Parameter
with
dropdown
box
Solution: Create an additional dataset that with populate the parameter dropdown
box. Change the available values page of the parameter to get values from a query.
Select the dataset that you created to populate the dropdown box.
Solution: Cascading parameters means one parameter can populate the contents of
the next parameter. Create additional datasets to populate each of the dropdown
box parameters you want. When writing these datasets you will want to make sure
that the lower level only shows values available in the higher level. The datasets
may look like this:
Select distinct EnglishCountryRegionName From DimGeography
Select distinct StateProvinceName From DimGeography
Cascading
Parameters
Solution: Install and configure Reporting Services add-in for SharePoint for your
version of SharePoint. Set the Deployment properties of the Report project to the
following:
Deploying
to
SharePoint
Setting up a
TargetDatasetFolder
http://yourservername/site/library/datasets
TargetDataSourceFolder
http://yourservername/site/library/datasources
TargetReportFolder
http://yourservername/site/library/reports
TargetReportPartFolder
http://yourservername/site/library/reportparts
TargetServerURL
http://yourservername/
Solution: Right-click on the textbox you wish to allow the drillthrough action and
drillthrough
report
select Text Box Properties. Select the Action page and select which type of object
you want to drillthrough to (Go to report, Go to bookmark, or Go to URL).
Creating a
Document
Map
Solution: Document Maps provide an easy way to navigate through a large report
with a table of contents for your report. To add a Document Map to a report rightclick on a row or column grouping (this assumes you have already added a grouping
to the report) and select Group Properties. On the Advanced page you will find the
Document map property where you will select the fields to add to the table of
contents.