Using Superscript Characters in DAX Measures

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!

Single Card with Quartiles.png

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.

DescriptionSuperscript
Superscript 0⁰
Superscript 1¹
Superscript 2²
Superscript 3³
Superscript 4⁴
Superscript 5⁵
Superscript 6⁶
Superscript 7⁷
Superscript 8⁸
Superscript 9⁹
DescriptionSubscript
Subscript 0₀
Subscript 1₁
Subscript 2₂
Subscript 3₃
Subscript 4₄
Subscript 5₅
Subscript 6₆
Subscript 7₇
Subscript 8₈
Subscript 9₉
DescriptionFractions
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

Completed Amount & Quartile =
VAR One = "¹"
VAR Two = "²"
VAR Three = "³"
VAR Four = "⁴"
VAR Quartile = [Completed Quartile]
VAR Amount = [Completed Amount]
VAR Result =
    SWITCH (
        TRUE (),
        Quartile = 1, Amount & " " & One,
        Quartile = 2, Amount & " " & Two,
        Quartile = 3, Amount & " " & Three,
        Quartile = 4, Amount & " " & Four
    )
RETURN
    Result

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.

Posted on May 12, 2020 and filed under Beginner, DAX, Visualizations.