Skip to main content

Lookup in SSRS 2008 R2

We use more than one dataset in many of the reports and we always think to join or merge datasets to provide a good solution in reports but we were not able to do it in 2005 or 2008, but now the time has come and microsoft has finally included some cool functions (Lookup, LookupSet, MultiLookup) in SSRS 2008 R2

Let's see how "LOOKUP" works here, Suppose we have a two datasets in the report, ex. one dataset (Store) has store information (StoreID, StoreName, Location, $ Sales etc, Date) and second dataset (Sales) has sales information. (StoreID, Date, Target $ Sales etc.)

I will directly grab a columns from first dataset but I also want to display target sales amount as a new column with this information. Now you can use Lookup function here in a new column

=LOOKUP(Fields!StoreID.Value,Fields!StoreID.Value,Fields!TargetSales.Value,"Sales")




In Lookup function, you need to pass following things:

  1.  Value form the first dataset to join with second dataset (ex. StoreID from dataset1)
  2.  Value from the second dataset and it look to be the same (ex. StoreID from dataset2)
  3.  The value that you want to display in reports from the second dataset (ex. TargetSales)
  4.  Name of the second dataset (ex. “Sales”)

- Hardik

Comments

Popular posts from this blog

ALL as a parameter value in ssrs oracle sql

In some cases as per the requirements you will need to add 'ALL' as an independent parameter value (not a multivalue parameter) 1) Create a new dataset to populate parameter values Ex: select distinct city from table1 where city is not null        union       select 'ALL' as city from dual       order by 1 2) Modify your main dataset query Ex: where (city = :city or 'ALL' = :city) Thank you

_x003C_none_x003E_ FlatFile Error in SSIS

If you are receiving this error in your output file, It is because of the value in the text qualifier property (Text Qualifier = <none>).  When you export the data in a file, you might see the _x003C_none_x003E_ (x003C = "<" and none and x003E = ">") with your original field value. • Do not open the connection manager editor once you finalize everything and just clear out the <none> value  from the property window on the right side (Do not open show editor) and save it. You’re done. • Other way around, You can also define the Expression value for the text qualifier and provide (“”) as a value in the expression. Go to the property --> Expression --> Select the Text qualifier from the drop down list --> provide the expression value (“”)

Default values for a date parameter in SSRS

We can use sql queries or some of the cool expressions available in SSRS to set default date parameters: Set First Day of previous week (Monday) =DateAdd(DateInterval.Day, -6,DateAdd(DateInterval.Day, 1-Weekday(today),Today)) Set Last Day of previous week (Sunday) =DateAdd(DateInterval.Day, -0,DateAdd(DateInterval.Day, 1-Weekday(today),Today)) Set First Day of Current Week (Monday) =DateAdd("d", 1 - DatePart(DateInterval.WeekDay, Today(),FirstDayOfWeek.Monday), Today()) Set Last Day of Current Week (Sunday) =DateAdd("d" ,7- DatePart(DateInterval.WeekDay,Today(),FirstDayOfWeek.Monday),Today()) Set First Date of last month =DateAdd("m", -1, DateSerial(Year(Now()), Month(Now()), 1)) Set Last date of last month =DateAdd("d", -1, DateSerial(Year(Now()), Month(Now()), 1)) Set First date of current month =DateSerial(Year(Now()), Month(Now()), 1) Set Last date of current month =DateAdd("d",-1,(DateAdd("m", 1,...