Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I was helping out in the Power BI Community and I came across the following requirement.
The user had sales figures and based on the Previous month, they wanted to have an arrow showing if it was up or down. As well as if there was no data to say that there was no data. So this is how I achieved this below.
The first thing that I did was to create a Date table and link this to my table above.
This ensured that when I wanted to create my PREVIOUSMONTH DAX measure it would be simple and easy.
I did it using my blog post: Power BI – How to Easily Create Dynamic Date Table/Dimension with Fiscal Attributes using Power Quer...
Once I had my Date Table I then created the relationship between my Sales Data table and my Date Table
Next I created my Previous Month measure with the following DAX Syntax
Previous Month Sales =
CALCULATE ( [Sales Amount], PREVIOUSMONTH ( 'Date'[Calendar Date] ) )
Now in order to get the Unicode Characters I followed the very interesting blog post by Chris Webb: The DAX Unichar() Function And How To Use It In Measures For Data Visualisation, in which I learnt how to use Unicode Characters in a measure.
Next I found the following website which contained the Unicode numbers for my arrows I required.
https://unicode-table.com/en/sets/arrows-symbols/
I then made a note of the following ones that I wanted to use
The final piece was where I created the Arrows measure.
Below is the DAX Syntax with an explanation afterwards
Arrows = SWITCH(
TRUE(),
ISBLANK([Previous Month Sales]),BLANK(),
|| ISBLANK([Sales Amount]),BLANK(),
[Sales Amount] <= 0, "No Data",
[Sales Amount] >= [Previous Month Sales],UNICHAR(9650),
[Sales Amount] <= [Previous Month Sales],UNICHAR(9660),
BLANK()
)
Below is the outputted table, which is doing as what was required.
As you can see from above being able to make sure of the Unicode Characters can make your dataset that much easier to read.
You can view it here: PBI – Unicode Measures
You can download the Sample File here: PBI – Unicode Measures.pbix
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.