Hey data fans! Today I want to share with you a technique for using superscript ASCII characters within DAX measures. This request came from a client who wanted to create a card very similar to what see on the right. Where a regular (amount) value was displayed on the left, with a superscript value (quartile) was displayed on the right.
Id’ initially thought this would require changing the font size for the specific quartile metric. Which I know isn’t possible to apply to individual characters. However, after some robust Google searching I discovered that there are ASCII characters for superscript numbers!
I’ll note that that cool looking card (above) with a colored status bar and fancy details is a layered visual I built in a previous video. If you’re interested in finding out more about that check out the blog post here.
In fact, I found some really useful ASCII characters for: superscript, subscript, and fractions! So I’m going to supply tables of all of these values for you in table formats below for easy reference in the future. 😃
One thing to note, I wasn’t able to find a character for every fraction in the list below. They seem to jump around a bit, not entirely sure why this is but just wanted to mention this.
Description | Superscript |
---|---|
Superscript 0 | ⁰ |
Superscript 1 | ¹ |
Superscript 2 | ² |
Superscript 3 | ³ |
Superscript 4 | ⁴ |
Superscript 5 | ⁵ |
Superscript 6 | ⁶ |
Superscript 7 | ⁷ |
Superscript 8 | ⁸ |
Superscript 9 | ⁹ |
Description | Subscript |
---|---|
Subscript 0 | ₀ |
Subscript 1 | ₁ |
Subscript 2 | ₂ |
Subscript 3 | ₃ |
Subscript 4 | ₄ |
Subscript 5 | ₅ |
Subscript 6 | ₆ |
Subscript 7 | ₇ |
Subscript 8 | ₈ |
Subscript 9 | ₉ |
Description | Fractions |
---|---|
One Half | ½ |
One Third | ⅓ |
Two Thirds | ⅔ |
One Fourth | ¼ |
Three Fourths | ¾ |
One Fifth | ⅕ |
Two Fifths | ⅖ |
Three Fifths | ⅗ |
Four Fifths | ⅘ |
One Sixth | ⅙ |
Five Sixths | ⅚ |
One Eigth | ⅛ |
Three Eights | ⅜ |
Give Eigths | ⅝ |
Seven Eigths | ⅞ |
An important thing to note is that even though these characters LOOK like numbers, they are actually text. So they’ll need to be concatenated together with the actual value amount in the DAX measure.
Now, for the measure itself I declared some variables, most importantly I created a variable for each superscript “quartile” amount that the client wanted. Then used a switch function to check what the original numerical quartile value was, and provided the concatenated result based off that.
DAX Measure Code Block
The great thing with DAX code like this, is that is can be customized to fit any business need. So hopefully you now have one more set of tools you now know can be integrated into your reporting.