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 = 1Amount & " " & One,
        Quartile = 2Amount & " " & Two,
        Quartile = 3Amount & " " & Three,
        Quartile = 4Amount & " " & 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.