Custom Visibility Toggling SSRS 2008

A while back I wrote a post about how to toggle the visibility of rows/columns in tables/matrices for SSRS 2005. In the comments of that article someone asked how this was done in SSRS 2008. The short answer was that the method is the same. However, setting all the properties can be confusing as their whereabouts is a little different. Hopefully this post will clear things up.

Let’s do this by way of example:

I created a project with a single report. The Data source is AdventureWorks2008 and we are looking at Total Sales figures by Year & Month (keep it simple right?). I have set up a matrix object and added the required fields and set subtotals for Month & Year. See Fig 1. below:

Objective: Enable Toggling of the Month group, using the Year Group as the Toggle Item

At this point I want to point out two key areas, as this is where we will be concentrating our efforts:

  1. The Row/Column Groups section at the bottom of the designer
  2. The Visibility Properties at the bottom right corner (Last item in the Properties list – but only when an object is selected)

Now, select the drop-down arrow for the Month Row group (See Fig 2.), choose Properties and then select the Visibility tab.

The objective is to enable toggling of the Month rows in the Matrix. We could choose to Show or Hide the Month rows when the report is initially run, or to make this decision based on an expression. Using an expression will determine which rows are expanded and which are collapsed when the report is run initially. I have chosen to use an expression:

=IIF(Fields!YEAR.value=2001, False, True)

This says that if the Year group value is ‘2001’ then show the Month Sales Total values (‘Expanded’), else Hide the Month Sales Total values (‘Collapsed’). See Fig 3. below:

Also note (in Fig 3. above) that I have set the YEAR cell as the Toggle Item. We’ll configure this next.

Once you have set the above properties go back to the designer and highlight the YEAR cell in order to view its properties. These should be on the bottom right, otherwise right-click the cell to bring up the properties window. Find the Visibility > InitialToggleState property and set it using the following Expression:

=IIF(Fields!YEAR.Value = 2001, True, False)

This says that if the Year group value is ‘2001’ then show the toggle icon as ‘Expanded’ (True), else show it as ‘Collapsed’ (False). This allows us to ensure that we are in sync with the expression we used to set the initial visibility of the Month rows. Fig 4. shows the end result of all this hard work:

The Visibility Properties

Understanding what each of the three visibility properties does will help to use them effectively.

Hidden – Can be set to either ‘True’ or ‘False’. This can be done by selecting True or False from the drop down, or by using an expression to set either of those values after evaluating a condition. True equates to the object being hidden and False to the object being shown (tricky eh?).

InitialToggleState – This is only applicable if the object that you have selected can toggle the visibility of other objects. It refers to the state of the toggle icon and can either be ‘Collapsed’ (‘+’) or ‘Expanded’ (‘-‘). As explained by way of example above, setting this to ‘’True’ sets the icon to the ‘Expanded’ state, and False to the ‘Collapsed’ state.

ToggleItem – Use this property to set the object that will enable the user to toggle the visibility of another item. In the example above, I have chosen YEAR as my toggle item for the Month Group.

Beware the Gremlins

You need to be aware of setting properties for the right objects or groups, or you may find that your report does not display correctly:

Fig 4. shows what happens when you set the Visibility properties for the Month & Data CELLS in the report instead of the Month Group properties. Setting the Month Group visibility properties means that you won’t get that nasty white space, and there’s no need to set the visibility of the cells (in this instance).

I have placed the example project in a nice little zip file for all you folks that might want such a thing.

Download Reports (.RDL) files for editing (SSRS 2005)

If you ever happen to be in a situation were you do not have access to or have ‘misplaced’ the SSRS report files (.rdl) and you need to edit one (or more) of the reports on your server, there is an easy way to download the .rdl files.

Follow these easy steps:

  1. Open SQL Server Management Studio,
  2. Log on to the Reporting Services Instance that contains the reports you are looking for
  3. Browser through the directory structure to the report that needs to be updated
  4. Right-click the report and choose Edit…
  5. Now follow the prompts to save the file to a destination of your choice
  6. Open BIDS & create a new project/solution
  7. Import the (previously) saved .rdl file into your SSRS project.
  8. Edit away to your hearts content….

 

I’m not going to ask why you don’t have access to or have misplaced the files in the first place (No source code management? Seriously?). I am sure there are a myriad of reasons that you can come up with. This post merely provides a quick way to recover your files and continue edits/updates that may be required.

SQLBits V – Conference & Session Recap (Part II)

This is the second part in my recap of SQLBits V. You can read Part 1 here.

Sessions

I was assigned as a room monitor on the Saturday, and as 3 of the sessions I was planning on attending were in the BI track, this is where I ended up. The day for Room 1 went as follows:

Getting Dimensional with Data -  Chris Testa O’Neill (Blog | Slides)

Chris took us through the basics of building a cube, highlighting the use of data sources and data source views, the importance of dimensions and hierarchies, and of course the measures that will hold the business metrics. This was a good talk on getting started with building your first cubes.

A Whistle Stop Tour of SSIS Add-ins – Jamie Thomson (Blog | Twitter | Slides)

Jamie introduced us to a number of free/paid for SSIS add-ins. He described each add-in, how it was configured and demoed a practical use for each. I have already written about this session in Part 1 of the Conference Recap. Jamie put a lot of work into his demos, so a big thanks to him.

Self Service Business Intelligence (Project Gemini) – Bob Duffy (Blog | Slides)

Bob took us once again through building a business intelligence solution with Office 2010 and Gemini. It seems that no matter how many times I see presentations on this stuff I don’t get tired of it. Looking forward to the moment I can use these tools in a commercial setting. Whenever that might be….

SSIS in SQL Server 2008 – Allan Mitchell (SQLIS.com | SQLDTS.com| Slides)

Allan did a great job (even though he overran his session by ‘a few minutes’) of informing us of a couple of differences in Threading between SSIS in SQL Server 2005 & 2008, why you need to be using the Cache & the Lookup Transform, the Data Profiling Task and Change Data Capture. Another enjoyable and informative session.

Report Builder 3 – Andrew Fryer (Blog | Twitter | Slides)

Andrew wowed us all. Again. Even with some demo trouble (he was plagued with ‘technical issues’) it was a fabulous session. He took us through all the features of Report Builder 3 as a Managed Self-Service BI tool. Items to note:

  • The Tablix Object
  • Improved Visualizations (Better Charts & Gauges, Maps, Sparklines, Data Bars, Indicators)
  • Interesting layouts (see slides)
  • Support for Spatial Data
  • Integration with Virtual Earth tiles.
  • Multiple Map Layers
  • A number of Layout enhancements (new functions, new data sources, Expression-based page breaks & chart headers, Excel tab naming, Bottom-to-top text rotation)
  • Aggregating aggregates

This was the last presentation of the day and of the conference and it ended on an high note.

Everyone then piled out into the foyer for drinks & games. About an hour after the social started Simon gathered everyone for prize giving – There were several prizes and winners were chosen by selecting completed feedback forms from a box (that contained all of them). I couldn’t believe it (cue Victor Meldrew). On the fourth attempt a feedback form of mine was pulled out and my name was called. Score! I still wonder at how the Redgate SQLComapre license was still there for the taking. This is after 3 other winners had taken mice, & webcams from the pile. I think I did pretty well. Thanks Redgate!

Volunteering

As I have mentioned before, SQLBits is a not commercial conference. It is organised and run by a handful of professionals that do it in their own time. I offered to be one of the helpers at this November’s conference and was glad I did so, as I got to meet and interact with a number of great people. It can sometimes be difficult to start a conversation with someone you don’t know (as I mentioned here) unless you have something in common, or an icebreaker. Volunteering can be the icebreaker. It forces you to meet a bunch of new people and gets the ball rolling.

So what did volunteering at SQLBits involve? About an hour of my time on the Friday evening, and playing room monitor in one of the rooms (BI Track) for the day – which meant that I couldn’t attend all of the sessions that I was aiming to, but as most of them were in the same room this wasn’t too much of an issue for me. To be honest, it was a lot less work than I had expected – note to self: must get involved earlier next time.

And what did I gain out it? A better understanding for what is involved in organising a SQLBits conference, meeting and conversing with the organisers, speakers and other volunteers, making new contacts and friends, being part of the community, a wonderful dinner late on Saturday night, and a great bonus from the organisers which was totally unexpected. So a HUGE thanks to Simon, Chris, James, Darren, Martin & Allan. You have pulled off (another) great conference and I am sure that I am not alone in saying that I can’t wait for the next one.

The People I met

Meeting more sql folks was one of my goals for the conference and I think I did pretty well. What remains to be seen is if I managed to leave a good enough impression. Over the two days I was at SQLBits I had the privilege of meeting and chatting to a number of people, some for just a brief few minutes, others for good enough chunk of time to get to know them a little better. Here’s a few of those awesome folks:

A fantastic group of people, all knowledgeable in their own sphere of SQL Server, and great personalities. I found I had the best conversations later in the evening once things had quietened down a bit. I think it would be great if there were more opportunities for quiet times like these, as sometimes they are of the most benefit. I believe that some others actually forego sessions when they’re having a great conversation with a new (or indeed old) acquaintance.

It would be nice to see a little more time (and possibly structure) attributed to mealtimes during the conference. These are times that could be used to great benefit for that all important networking. I have a few ideas that I’d like to pass around and will possibly write another post about it later. At the very least I’ll pass them along to the organisers (or possibly something that I could organise???). For those that were lucky enough to go to the PASS Summit, what opportunities did you have for catching up with old friends & getting to know some new folks?

So, what did I learn at SQLBits?

I have mentioned previously the sessions that were my highlights and have gone into some details there. This is a list of other things

  • Arrive early – to the conference and to each session. You’ll get the lay-of-the-land and you get to meet a few people before it begins to get crazy. At the very least, get to your sessions on time. Speakers have a set time to give their presentations and need to have some time for questions. Your questions. If they have to start late due to interruptions, there’s less or no time for questions.
  • Leave late – Stay over on the last evening. I found this to be the best time for conversations with speakers, MVPS, organisers and attendees (that also stayed over). The stress of the sessions and the conference has abated and people are much easier to talk to and get to know.
  • A book/laptop/netbook/napkin/whatever – Bring something to take notes. Anything. Just ensure that you take notes for things that spark your interest. The sessions can be fairly intense (speakers try and pack in as much as they can) and your brain will be overflowing pretty quick (well, maybe I only speak for myself here), so taking notes enables you to revisit the key points at a later date when you have the time.
  • Business/Contact cards – get some made and hand them out. I met many more people than those on my list but due to my overflowing brain, just couldn’t keep track. Go get some cards people! If you weren’t on the receiving end of one of mine (care of moo.com), here’s an electronic copy:
  • Luke_Hayler_Contact_Cards Luke_Hayler_Contact_Cards
  • Ask questions – if you don’t you’re missing out on some valuable first-hand information from some of the brightest sql folks around. It also helps to prepare some ahead of time. The sessions and speakers are listed well ahead of time, so take a note of those sessions you would like to attend and write down the questions you may have.
  • Time to digest – set aside some time, even just an hour, during the day to digest what you’ve learned and who you may have met. You’ll be surprised how easily this information will escape you if you if don’t. So, got get your favourite beverage, find a quiet spot and go through your notes, you may find that you have a few questions, which you can now go pose to the speaker of the session, or indeed any others.
  • Attend a Donald Farmer presentation. ‘nuff said.
  • PowerPivot, Excel 2010, Reporting Services in 2008 R2 – are all pretty awesome. I can’t wait to get my hands on these and building some mind blowing data analysis and reporting solutions.

Some Suggestions & Ideas

  • Better information about sessions – I found that while most of the sessions were well described (in the schedule), there were some that held little or not information about the session, and one or two that had misleading titles. This makes it pretty difficult to know what to expect when you are attending. Given that feedback is so valuable to speakers (and organisers), I would have though that if someone’s expectations were not met then the speaker might receive poor feedback. Ambiguity about the session also leads to more disruptions – people will leave during the session if they feel that it’s not quite what they expected. Personally, I would like to know exactly what the session is about before I make a decision to attend. Most of the speakers I saw had an agenda slide. This is perfect for the session description.
  • Several screens in the foyer (TVs/projectors/etc) with any important announcements (room updates, next sessions, etc)
  • Live Twitter stream in each session room – which could be managed by a room monitor perhaps.
  • More time to mingle – I know that the sessions are the core of the conference, but wouldn’t having more time to get to know people and ask the MVPs/Speakers/other attendees questions help too? There was barely enough time between the sessions to get a cup of coffee & a biscuit (or cookie for our US readers) let alone meeting and having a meaningful conversation. I am not sure how much of a nightmare it would be to start sessions earlier and finish later in the day, but it might make the day easier to handle – from an attendee point of view.

Did you attend SQLBits? Do you have any comments on any of the above Suggestions & Ideas (or indeed anything else I’ve mentioned)? Let’s hear from you!

You’re still reading this??

This has been a fairly epic post, so if you have made it all the way down here I applaud you. Thanks for sticking it out!

This has been my experience. I hope it provides a good summary of what SQLBits is about and if you weren’t already thinking about going to the next one you should definitely make plans to do so. It’s worth it.

See you at SQLBits VI!

The DatePart() Function in SSRS

Using the DatePart() Function in SSRS can be tricky, even at the best of times. I have pulled my hair out too often trying to remember what syntax should be used, so have resorted to writing down all my findings. This is so that you don’t have to go through the same agony & frustration as I did, as well as for my own benefit (my memory is shot…)

What it does: Returns an Integer containing the specified part of a given date

Syntax: DatePart(interval, date[,firstdayofweek[,firstweekofyear]])

There are two ways to use this function:

  • Using the DateInterval collection
  • Using a string expression
 
Using the DateInterval Collection

Let’s start with an example:

To return the current month: =DatePart(DateInterval.Month, Today())

Now, in the expression builder (in BIDS), it will look like there’s something the matter with what we have just written:

You can ignore this, the expression will work. An important point to note when using the DateInterval collection, is that you must use a date that is of type Datetime. If you use a string representation of a date (“2009/11/13”), then you’ll need to convert this to Datetime using CDate(“2009/11/13”) before the expression will work. Thus:

This will work:  =DatePart(DateInterval.Month, CDate(“2009/11/13”))

This won’t:  = DatePart(DateInterval.Month, “2009/11/13”)

When you use the DatePart function to identify the day of the week you can specify what the First Day Of The Week is (defaults to Sunday if this is not specified). You can do this by accessing the FirstDayOfWeek collection. Example – To Return the day of the week, specifying Monday as the first day of the week:

DatePart(DateInterval.Weekday, CDate(“2009/11/13”), FirstDayOfWeek.Monday) returns 5 (Friday)

All the possibilities for using the DatePart() function with the DateInterval Collection:

The following table shows all the possibilities for the DatePart Function using the DateInterval collection. All expressions use a Parameter called MyDate (type = Datetime), which has a value of “2009/11/13 12:34:23”

Expression Result
DatePart(DateInterval.Second, Parameters!MyDate.Value) 23
DatePart(DateInterval.Minute, Parameters!MyDate.Value) 34
DatePart(DateInterval.Hour, Parameters!MyDate.Value) 12
DatePart(DateInterval.Weekday, Parameters!MyDate.Value, FirstDayOfWeek.Monday) 5
DatePart(DateInterval.Day, Parameters!MyDate.Value) 13
DatePart(DateInterval.DayOfYear, Parameters!MyDate.Value) 317
DatePart(DateInterval.WeekOfYear, Parameters!MyDate.Value) 46
DatePart(DateInterval.Month, Parameters!MyDate.Value) 11
DatePart(DateInterval.Quarter, Parameters!MyDate.Value) 4
DatePart(DateInterval.Year, Parameters!MyDate.Value) 2009

 

Using a String Expression

Again, let’s start with an example:

To return the current month:  =DatePart(“m”, Today())

Using a String expression for your interval enables you to use a date that is of datatype String:

=DatePart(“m”, “2009/11/13”)

All the possibilities for using the DatePart() function with a String Expression:

As noted previously, using a string expression for the interval allows you to use a date value that is of the String datatype. You can of course use a Datetime value if you wish to.

This table shows all the possibilities for the DatePart function using a String Expression for the interval. All expressions use a Parameter called MyDate (type = String), which has a value of “2009/11/13 12:34:23”

Date Part Expression Result
Second DatePart(“s”, Parameters!MyDate.Value) 23
Minute DatePart(“n”, Parameters!MyDate.Value) 34
Hours DatePart(“h”, Parameters!MyDate.Value) 12
Day of Week DatePart(“w”, Parameters!MyDate.Value, FirstDayOfWeek.Monday) 5
Day of Month DatePart(“d”, Parameters!MyDate.Value) 13
Day of Year DatePart(“y”, Parameters!MyDate.Value) 317
Week of Year DatePart(“ww”, Parameters!MyDate.Value) 46
Month DatePart(“m”, Parameters!MyDate.Value) 11
Quarter DatePart(“q”, Parameters!MyDate.Value) 4
Year DatePart(“yyyy”, Parameters!MyDate.Value) 2009

 

Is there a preferred method?

Ul
timately, no. At the end of the day, all the results are the same. What is my preference? I use the DateInterval collection, mainly becuase I like that fact that you can’t get confused about which date part you are using (w/ww, y/yyyy, n….). It’s very clear to anyone who is reading the code that (for example) DateInterval.WeekOfYear refers to the week of the year and nothing else. It also forces you to use a Datetime Value, which safeguards against invalid dates (sort of).

I hope this clears things up a little!

Gearing up for SQLBits V

SQLBits is almost upon us. In less than 10 days, around 400 people will be descending on the Celtic Manor in Newport, Wales for the 5th instalment of what I am led to believe is a first rate conference. Great speakers, great sessions, awesome venue, _____________ attendees. That space is intentional. I plan to fill it in once I’ve had the pleasure of meeting a bunch of you and making a few (hundred) new friends.

Preparations

So I’ve been reading a lot in the last few weeks. As the PASS Summit has just come and gone, there are a multitude of blog posts out there about conference preparation, travelling tips, ways to cut costs, what type of questions you should and shouldn’t be posing to speakers/vendors/other attendees, starting conversations with others, making new acquaintances, as well as those about the actual conference.

My preparations have be slow and steady. Research has been the main focus, with understanding what sessions are on offer, who the speakers are and what events will be taking place ‘after hours’. The first two items here are easily accomplished by venturing over to the sqlbits website where you will find a description of each of the intended sessions, the speakers and their bios with links to their websites and other web presences (twitter) if any exist – most do, but there are a few who seem to be ghosts on the information super-highway (ha! when was the last time that you heard that phrase…). Say what you like, but I believe that if you are a speaker then you should at least have a spot on the intertubez where people can find out more about you and download your slides.

I’ve ordered a bunch of business cards from moo.com. They’re of the mini variety and hold all the vital contact info as well as a mug shot of yours truly – so you can remember who to avoid look for at the next meet…

I’ve started to put together a few questions for key people that I’m aiming to stalk find, meet and get to know a little better. I’ll bribe them with whatever they need to persuade them to stick around long enough find out who I am and to answer my questions – I find beer works pretty well in most cases.

What to do, Where to go

In terms of sessions that I’m thinking of attending, it depends on the schedule. I’ve been informed however, that although the schedule for the sessions has been done, ‘technical difficulties’ have meant that they are not yet available for the rest of us. Let’s hope they fix the issue soon… wink wink nudge nudge. Once I know when the sessions are to take place I’ll post a list that I’ll be attending.

On to the important stuff. Social Events! I have been searching for a while now, but have still to find any reference to the ‘after hours events’ – think organised dinners and karaoke sessions at the PASS Summit. This is due to the fact that either there are no events (yet) or they haven’t been adequately advertised. So, if any of you readers do have knowledge of any planned social events, please let me know. If there aren’t any planned events, well…, we’ll have to change that. Pronto.

I’ll see you there. SQLbits 2009.