Headder AdSence

SSRS Reports – Displaying Superscripts and Subscripts

SSRS Reports – Displaying Superscripts and Subscripts


S Superscripts and Subscripts
At some point in time you may find that you need to display numbers in superscript or subscript format in a SSRS report. I ran into it recently in a report that required footnotes describing the contents of columns. If you ever need to display chemical or mathematical formulas you may also find number subscripting and superscripting necessary. Dig into the font properties available in SSRS, and you will not find these options available.

Using Unicode Fonts to Display Superscripts and Subscripts

The good news is, there is another method available that will allow you to display numbers in the superscript or subscript styles in a SSRS report. Unicode fonts include special characters that display as superscripted and subscripted versions of the normal number characters. The following table lists the integer code points that represent the Superscript and Subscript versions of the number characters. We will be able to display these characters directly or by using the character codes in an expression in SSRS.
NOTE: It’s a good idea to have an idea of your target audience if you’re thinking about using this Unicode fonts method for displaying superscripts and subscripts. For your typical business user working on a desktop or laptop, they should not encounter any problems. If you expect to have users viewing your SSRS reports using mobile devices or computers running antiquated operating systems or web browsers, you may run into situations where some of these Unicode characters may not be display properly.
NumberSuperscriptSubscriptSuper. CodeSuper. UsageSub. codeSub. Usage
08304ChrW(8304)8320ChrW(8320)
1¹185ChrW(185 )8321ChrW(8321)
2²178ChrW(178 )8322ChrW(8322)
3³179ChrW(179 )8323ChrW(8323)
48308ChrW(8308)8324ChrW(8324)
58309ChrW(8309)8325ChrW(8325)
68310ChrW(8310)8326ChrW(8326)
78311ChrW(8311)8327ChrW(8327)
88312ChrW(8312)8328ChrW(8328)
98313ChrW(8313)8329ChrW(8329)
So let’s see how it works. Let’s pretend as an example that you have a column of a tablix in your report and you want to display the following text in that column’s header:
"CO₂ Levels"

Choosing a Unicode Font

SSRS Superscripts and Subscripts Select Unicode FontFirst, be sure to choose a Unicode font to use for your header text that includes these special Superscript and Subscript characters. I’ve seen it recommended to use Lucida Sans Unicode elsewhere. I do like the look of the Superscript and Subscript characters in that font, but I found in some testing in my environment that the number 4 was not being displayed properly in Internet Explorer browsers. I chose instead to use the fontArial Unicode MS and that cleared up the IE issue for me.

Methods For Using Unicode Fonts To Display Superscripts and Subscripts

The first method you can use to include these characters is just to copy and paste them where you need them as plain text. Keep a link to this article handy, and any time you need to use the characters grab what you need from the above table. Assuming you’ve selected a compatible font, you should not have any problems seeing your superscripts and subscripts both while you’re designing your SSRS report and when you’ve deployed it.
Using our “CO₂ Levels” example, try copying and pasting the example text directly into the column header in your report that you’ve already set up with a good Unicode font. See how the subscripted 2 appears just as it should? Now try directly copying a superscript character from the table above and using it instead. It’s that easy!
Another option for displaying these superscript and subscript characters is to use the Visual Basic ChrW() function in an expression. The ChrW() function will display characters based on the Unicode code point integer we give it. For example, we could create this placeholder expression for “CO₂ Levels” by using theSub. Code for 2 from the table above:
="CO" & ChrW(8322) & " Levels"
But what if you are using a font in your SSRS report that doesn’t support these Superscript and Subscript characters? Say your report uses Times New Roman, and you want to keep using that font. Easy, leave everything set up as it is in Times New Roman, and where you need to use a special character create aseparate placeholder expression just for it. In this case, your example may now look like this:
CO<<expr>> Levels
Then, in the placeholder’s properties, make sure you choose an appropriate Unicode font that includes the superscript and subscript characters. Now in your placeholder you can paste in the appropriate character you need or set up an expression similar to this:
="" & ChrW(8322)
There are many other Unicode characters, of course, that you may want to display in your SSRS reports beyond the number set listed in the table above. You can find available characters in the Windows Character Map application or from a website like Unicode Map. These sources include the hexadecimal code point for the characters as well. To use that info in the ChrW() function you’d have to convert the hexadecimal number to a binary number, which can be done online with a tool like Math is Fun’s converter. From the Character Map image example below, subscript 2 is 2082 in hex, which if you do the math you’ll find is 8322 in decimal.
Subscript Character Map example
Here are a few other Unicode characters you may find handy to include in reports:
⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺ ⁻ ⁼ ⁽ ⁾ 
₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎
ᵃ ᵇ ᶜ ᵈ ᵉ ᶠ ᵍ ʰ ⁱ ʲ ᵏ ˡ ᵐ ⁿ ᵒ ᵖ ʳ ˢ ᵗ ᵘ ᵛ ʷ ˣ ʸ ᶻ
ᴬ ᴮ ᴰ ᴱ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴼ ᴾ ᴿ ᵀ ᵁ ᵂ
ₐ ₑ ᵢ ₒ ᵣ ᵤ ᵥ ₓ
½ ¼ ¾ ⅓ ⅔ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞ № ℠ ™ © ®

Conclusion

Now you know of a couple of ways to use Unicode characters to include superscripts and subscripts in your SSRS reports.  Hopefully you’ll find these methods useful, and as always, feel free to share your thoughts or how this article helped you.

1 comment: