SlideShare a Scribd company logo
SSRS Expressions
 To display the current data and Time 
=Now() 
 The following expression formats the SellStartDate 
value as MMM-YY. 
=FORMAT(Fields!SellStartDate.Value, "MMM-yy") (OR) 
=FORMAT(Fields!SellStartDate.Value, dd/MM/yyyy“)
• The following example displays the start date of the 
current year. 
=DateAdd(DateInterval.Year,DateDiff(DateInterval.Year,C 
Date("01/01/1900"),Now()),CDate("01/01/1900")) 
 The following expressions display various dates based 
on a date parameter value selected by the user.
 Yesterday 
=DateSerial(Year(Parameters!TodaysDate.Value),Month(Parameters! 
TodaysDate.Value),Day(Parameters!TodaysDate.Value)-1) 
 Two Days Ago 
=DateSerial(Year(Parameters!TodaysDate.Value),Month(Parameters! 
TodaysDate.Value),Day(Parameters!TodaysDate.Value)-2)
 One Month Ago 
=DateSerial(Year(Parameters!TodaysDate.Value),Month(Parameters! 
TodaysDate.Value)-2,Day(Parameters!TodaysDate.Value)) 
 One Year Ago 
 =DateSerial(Year(Parameters!TodaysDate.Value)1,Month(Parameters! 
TodaysDate.Value),Day(Parameters!TodaysDate.Value)) 
 Two Years Ago 
=DateSerial(Year(Parameters!TodaysDate.Value)-2,Month(Parameters! 
TodaysDate.Value),Day(Parameters!TodaysDate.Value))
 Trimming DOMAINusername to just the user name 
=Right(Parameters!User.Value, Len(Parameters!User.Value) - 
InStr(Parameters!User.Value, "")) 
 Display the selected values from a multivalue parameter 
= Join(Parameters!MySelection.Value) (OR) 
=”Report for “ & JOIN(Parameters!MySelection.Value, “ & “)
 To combine the two string values in the text boxes. 
=Fields!FirstName.Value & vbCrLf & Fields! 
LastName.Value 
 The following expression displays values of the 
StartDate and EndDate parameters in long date 
format: 
=Format(Parameters!StartDate.Value, "D") & " through " 
& Format(Parameters!EndDate.Value, "D")
 To change the format of a ten-digit telephone number in a field 
from "nnn-nnn-nnnn" to "(nnn) nnn-nnnn": 
=System.Text.RegularExpressions.Regex.Replace(Fields!Phone.Value, 
"(d{3})[ -.]*(d{3})[ -.]*(d{4})", "($1) $2-$3") 
 The lookup function,The following expression displays the product 
name from a dataset (“Product”), given the product identifier to 
match on 
=Lookup(Fields!PID.Value, Fields!ProductID.Value, 
Fields.ProductName.Value, "Product")
 converts the constant 500 to type Decimal in order to compare it to 
a Transact-SQL money data type 
=CDec(500) 
 The following expression displays the number of values selected for 
the multivalue parameter MySelection. 
=CStr(Parameters!MySelection.Count) 
 Use multiple IIF functions can be placed in the fill color of a text box 
to change the background color depending on the value in the text 
box.
=IIF(Fields!PctComplete.Value >= 10, "Green", IIF(Fields!PctComplete.Value 
>= 1, "Blue", "Red")) (OR) 
=swithc(Fields!PctComplete.Value >= 10, "Green",Fields!PctComplete.Value 
>= 1,yellow,Fields!PctComplete.Value >= 15,Oranage, "True", "Red") 
 Test the value of the ImportantDate field and return "Red" if it is more 
than a week old, and "Blue" otherwise. It used to control the Color 
property of a text box in a report item 
=IIF(DateDiff("d",Fields!ImportantDate.Value, Now())>7,"Red","Blue")
 Test the value of the Department field and return 
either a subreport name or a null This expression can 
be used for conditional drillthrough subreports. 
=IIF(Fields!Department.Value = "Development", 
"EmployeeReport", Nothing) 
 To displayed only if the value of the field is not null. 
=IIF(IsNothing(Fields!LargePhoto.Value),True,False)
 To displays NA in the Month field when the field contains the value of 0 
=IIF(Fields!Month.Value=0,"NA",MonthName(IIF(Fields! 
Month.Value=0,1,Fields!Month.Value))) 
 This function can be useful in the header or footer of a group. The 
following expression displays the sum of data in the Order group or data 
region 
 =Sum(Fields!LineTotal.Value, "Order") 
 =Sum(IIF(Fields!State.Value = "Finished", 1, 0))
 changes the color of the text depending on the value of the Profit 
field 
=Iif(Fields!Profit.Value < 0, "Red", "Black") 
 To display alternates the background color of each row between 
pale green and white 
=Iif(RowNumber(Nothing) Mod 2, "PaleGreen", "White") 
 Using an expression for a specified scope, you may have to indicate 
the dataset for the aggregate function
=Iif(RowNumber("Employees") Mod 2, "PaleGreen", 
"White") 
 shows the table only if it has more than 12 rows 
=IIF(CountRows()>12,false,true) 
 To check the if the field exists in the report dataset 
after the data is retrieved from the data source 
=IIF(Fields!Column_1.IsMissing, true, false)
 Lookup To combine the two dataset columns in the single report 
item. 
=Lookup(Fields!SiteCode.Value,Fields!SiteCode.Value,Fields! 
DistributionPoint.Value, "DataSet2") 
 Lookupset 
Join(LookupSet(Fields!PID.Value , 
, Fields!Xtrnl_Award_Type.Value & " - " & Fields! 
Xtrnl_Award_Date.Value 
, "Awards"), ", ")
 Multi Lookup 
=Join(MultiLookup(Split(Fields! 
CategoryList.Value,","), Fields! 
CategoryID.Value 
,Fields!CategoryName.Value,"Category")), ", ")

More Related Content

PPT
Basic Operation in Excel and Eviews
DOC
Devry bis 155 final exam guide
PDF
Chapter 5 Capstone Project (completed solution)
PPT
Dervy bis-155-final-exam-guide-cool-clocks-inc-new
PDF
Has Many And Belongs To Many
PDF
Structured query language(sql)
PPT
Devry bis-155-final-exam-guide
DOCX
BIS 155 Education Specialist / snaptutorial.com
Basic Operation in Excel and Eviews
Devry bis 155 final exam guide
Chapter 5 Capstone Project (completed solution)
Dervy bis-155-final-exam-guide-cool-clocks-inc-new
Has Many And Belongs To Many
Structured query language(sql)
Devry bis-155-final-exam-guide
BIS 155 Education Specialist / snaptutorial.com

What's hot (16)

PDF
SAMSTAR: A Semi-automated Lexical Method to generate Star Schemas from an ERD
PDF
Bis 155 Exceptional Education / snaptutorial.com
PPTX
Excel tutorial
PPT
Devry bis-155-final-exam-guide-new
PDF
5 creating a_histogram
PPTX
2018 03 27_biological_databases_part4_v_upload
PPTX
Scoda openrefine-directordata
PPT
Dervy bis-155-final-exam-guide-music-on-demand-new
PPTX
GPREC DBMS Notes 1
DOCX
4)lab activity2 ms access
DOCX
BIS 155 Lessons in Excellence / bis155.com
DOCX
BIS 155 Inspiring Innovation -- bis155.com
DOC
Devry bis 155 final exam guide (music on demand) new
PPT
Thesis PPT
DOCX
BIS 155 Expect Success/newtonhelp.com
SAMSTAR: A Semi-automated Lexical Method to generate Star Schemas from an ERD
Bis 155 Exceptional Education / snaptutorial.com
Excel tutorial
Devry bis-155-final-exam-guide-new
5 creating a_histogram
2018 03 27_biological_databases_part4_v_upload
Scoda openrefine-directordata
Dervy bis-155-final-exam-guide-music-on-demand-new
GPREC DBMS Notes 1
4)lab activity2 ms access
BIS 155 Lessons in Excellence / bis155.com
BIS 155 Inspiring Innovation -- bis155.com
Devry bis 155 final exam guide (music on demand) new
Thesis PPT
BIS 155 Expect Success/newtonhelp.com
Ad

Similar to Ssrs expressions (20)

PDF
Introduction to DAX Language
PDF
DP080_Lecture_2 SQL related document.pdf
PDF
Stata cheatsheet transformation
PPTX
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
PPTX
Chris Seebacher Portfolio
PDF
Stata Cheat Sheets (all)
PDF
Stata cheat sheet: data transformation
PDF
Cheat Sheet for Stata v15.00 PDF Complete
PPTX
Business Intelligence Portfolio
PPTX
unit 1 ppt.pptx
PPTX
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
PPTX
Introduction to data analyticals123232.pptx
PPTX
1.2 Zep Excel.pptx
PDF
Sql saturday 829_decalogo_powerbi
PPTX
A picture speaks a thousand words - Data Visualisation with R
PPT
asdasdasdasdsadasdasdasdasdsadasdasdasdsadsadasd
PPTX
Baby-step tutorial on adding Dynamism in Chats (Ms Excel)
PPTX
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
PPTX
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
PDF
Simple Spreadsheet Tips
Introduction to DAX Language
DP080_Lecture_2 SQL related document.pdf
Stata cheatsheet transformation
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
Chris Seebacher Portfolio
Stata Cheat Sheets (all)
Stata cheat sheet: data transformation
Cheat Sheet for Stata v15.00 PDF Complete
Business Intelligence Portfolio
unit 1 ppt.pptx
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
Introduction to data analyticals123232.pptx
1.2 Zep Excel.pptx
Sql saturday 829_decalogo_powerbi
A picture speaks a thousand words - Data Visualisation with R
asdasdasdasdsadasdasdasdasdsadasdasdasdsadsadasd
Baby-step tutorial on adding Dynamism in Chats (Ms Excel)
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
Simple Spreadsheet Tips
Ad

Recently uploaded (20)

PDF
GSH-Vicky1-Complete-Plans on Housing.pdf
PPTX
2. Competency Based Interviewing - September'16.pptx
PPT
robotS AND ROBOTICSOF HUMANS AND MACHINES
PPTX
Causes of Flooding by Slidesgo sdnl;asnjdl;asj.pptx
PPTX
22CDO02-IMGD-UNIT-I-MOBILE GAME DESIGN PROCESS
PPT
EthicsNotesSTUDENTCOPYfghhnmncssssx sjsjsj
PDF
Urban Design Final Project-Context
PPTX
Evolution_of_Computing_Presentation (1).pptx
PPTX
LITERATURE CASE STUDY DESIGN SEMESTER 5.pptx
PPTX
NEW EIA PART B - Group 5 (Section 50).pptx
PDF
SOUND-NOTE-ARCHITECT-MOHIUDDIN AKHAND SMUCT
PPTX
Media And Information Literacy for Grade 12
PDF
Test slideshare presentation for blog post
PDF
Architecture Design Portfolio- VICTOR OKUTU
PPTX
Tenders & Contracts Works _ Services Afzal.pptx
PPTX
Presentation.pptx anemia in pregnancy in
PPTX
VERNACULAR_DESIGN_PPT FINAL WITH PROPOSED PLAN.pptx
PPTX
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
PPTX
Orthtotics presentation regarding physcial therapy
PDF
ART & DESIGN HISTORY OF VEDIC CIVILISATION.pdf
GSH-Vicky1-Complete-Plans on Housing.pdf
2. Competency Based Interviewing - September'16.pptx
robotS AND ROBOTICSOF HUMANS AND MACHINES
Causes of Flooding by Slidesgo sdnl;asnjdl;asj.pptx
22CDO02-IMGD-UNIT-I-MOBILE GAME DESIGN PROCESS
EthicsNotesSTUDENTCOPYfghhnmncssssx sjsjsj
Urban Design Final Project-Context
Evolution_of_Computing_Presentation (1).pptx
LITERATURE CASE STUDY DESIGN SEMESTER 5.pptx
NEW EIA PART B - Group 5 (Section 50).pptx
SOUND-NOTE-ARCHITECT-MOHIUDDIN AKHAND SMUCT
Media And Information Literacy for Grade 12
Test slideshare presentation for blog post
Architecture Design Portfolio- VICTOR OKUTU
Tenders & Contracts Works _ Services Afzal.pptx
Presentation.pptx anemia in pregnancy in
VERNACULAR_DESIGN_PPT FINAL WITH PROPOSED PLAN.pptx
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
Orthtotics presentation regarding physcial therapy
ART & DESIGN HISTORY OF VEDIC CIVILISATION.pdf

Ssrs expressions

  • 2.  To display the current data and Time =Now()  The following expression formats the SellStartDate value as MMM-YY. =FORMAT(Fields!SellStartDate.Value, "MMM-yy") (OR) =FORMAT(Fields!SellStartDate.Value, dd/MM/yyyy“)
  • 3. • The following example displays the start date of the current year. =DateAdd(DateInterval.Year,DateDiff(DateInterval.Year,C Date("01/01/1900"),Now()),CDate("01/01/1900"))  The following expressions display various dates based on a date parameter value selected by the user.
  • 4.  Yesterday =DateSerial(Year(Parameters!TodaysDate.Value),Month(Parameters! TodaysDate.Value),Day(Parameters!TodaysDate.Value)-1)  Two Days Ago =DateSerial(Year(Parameters!TodaysDate.Value),Month(Parameters! TodaysDate.Value),Day(Parameters!TodaysDate.Value)-2)
  • 5.  One Month Ago =DateSerial(Year(Parameters!TodaysDate.Value),Month(Parameters! TodaysDate.Value)-2,Day(Parameters!TodaysDate.Value))  One Year Ago  =DateSerial(Year(Parameters!TodaysDate.Value)1,Month(Parameters! TodaysDate.Value),Day(Parameters!TodaysDate.Value))  Two Years Ago =DateSerial(Year(Parameters!TodaysDate.Value)-2,Month(Parameters! TodaysDate.Value),Day(Parameters!TodaysDate.Value))
  • 6.  Trimming DOMAINusername to just the user name =Right(Parameters!User.Value, Len(Parameters!User.Value) - InStr(Parameters!User.Value, ""))  Display the selected values from a multivalue parameter = Join(Parameters!MySelection.Value) (OR) =”Report for “ & JOIN(Parameters!MySelection.Value, “ & “)
  • 7.  To combine the two string values in the text boxes. =Fields!FirstName.Value & vbCrLf & Fields! LastName.Value  The following expression displays values of the StartDate and EndDate parameters in long date format: =Format(Parameters!StartDate.Value, "D") & " through " & Format(Parameters!EndDate.Value, "D")
  • 8.  To change the format of a ten-digit telephone number in a field from "nnn-nnn-nnnn" to "(nnn) nnn-nnnn": =System.Text.RegularExpressions.Regex.Replace(Fields!Phone.Value, "(d{3})[ -.]*(d{3})[ -.]*(d{4})", "($1) $2-$3")  The lookup function,The following expression displays the product name from a dataset (“Product”), given the product identifier to match on =Lookup(Fields!PID.Value, Fields!ProductID.Value, Fields.ProductName.Value, "Product")
  • 9.  converts the constant 500 to type Decimal in order to compare it to a Transact-SQL money data type =CDec(500)  The following expression displays the number of values selected for the multivalue parameter MySelection. =CStr(Parameters!MySelection.Count)  Use multiple IIF functions can be placed in the fill color of a text box to change the background color depending on the value in the text box.
  • 10. =IIF(Fields!PctComplete.Value >= 10, "Green", IIF(Fields!PctComplete.Value >= 1, "Blue", "Red")) (OR) =swithc(Fields!PctComplete.Value >= 10, "Green",Fields!PctComplete.Value >= 1,yellow,Fields!PctComplete.Value >= 15,Oranage, "True", "Red")  Test the value of the ImportantDate field and return "Red" if it is more than a week old, and "Blue" otherwise. It used to control the Color property of a text box in a report item =IIF(DateDiff("d",Fields!ImportantDate.Value, Now())>7,"Red","Blue")
  • 11.  Test the value of the Department field and return either a subreport name or a null This expression can be used for conditional drillthrough subreports. =IIF(Fields!Department.Value = "Development", "EmployeeReport", Nothing)  To displayed only if the value of the field is not null. =IIF(IsNothing(Fields!LargePhoto.Value),True,False)
  • 12.  To displays NA in the Month field when the field contains the value of 0 =IIF(Fields!Month.Value=0,"NA",MonthName(IIF(Fields! Month.Value=0,1,Fields!Month.Value)))  This function can be useful in the header or footer of a group. The following expression displays the sum of data in the Order group or data region  =Sum(Fields!LineTotal.Value, "Order")  =Sum(IIF(Fields!State.Value = "Finished", 1, 0))
  • 13.  changes the color of the text depending on the value of the Profit field =Iif(Fields!Profit.Value < 0, "Red", "Black")  To display alternates the background color of each row between pale green and white =Iif(RowNumber(Nothing) Mod 2, "PaleGreen", "White")  Using an expression for a specified scope, you may have to indicate the dataset for the aggregate function
  • 14. =Iif(RowNumber("Employees") Mod 2, "PaleGreen", "White")  shows the table only if it has more than 12 rows =IIF(CountRows()>12,false,true)  To check the if the field exists in the report dataset after the data is retrieved from the data source =IIF(Fields!Column_1.IsMissing, true, false)
  • 15.  Lookup To combine the two dataset columns in the single report item. =Lookup(Fields!SiteCode.Value,Fields!SiteCode.Value,Fields! DistributionPoint.Value, "DataSet2")  Lookupset Join(LookupSet(Fields!PID.Value , , Fields!Xtrnl_Award_Type.Value & " - " & Fields! Xtrnl_Award_Date.Value , "Awards"), ", ")
  • 16.  Multi Lookup =Join(MultiLookup(Split(Fields! CategoryList.Value,","), Fields! CategoryID.Value ,Fields!CategoryName.Value,"Category")), ", ")