top of page
pbi_verkeersslachtoffers_overzicht.png
Post: Blog2_Post

DAN'S DAX TIPS

  • Foto van schrijverDaniël Krol

Custom KPI card


See that little green/red arrow in the upper-right corner of this KPI-card? It is just a little visual gimmick that makes it easier to see, whether the value that is shown in the KPI card is good or not. In this case, it shows whether the number of Road Casualties in the selected year is less, or more, compared to the year before. Unfortunately, there is not an easy method in Power BI to show such a visual reference. But it is not too hard also to accomplish. Read on, and I'll tell you which steps to follow and create your own stunning custom KPI card.


In the end, that little arrow is just a small KPI Card visual in Power BI. It is placed on top of the bigger KPI card that shows the number of casualties. The problem with KPI-cards is that they are only capable of showing text or numbers. But that is frankly the only thing that we need: showing text. The secret is that the arrows are JUST TEXT after all! Wo could have thought?


By using UNICHAR we can use a large list of characters, which also contains the UP arrow (11167) and the DOWN arrow (11165). But this list also contains a lot of other symbols, stars, large dots, etc, etc, etc... Don't you believe me? Check it here, or here, or here, or...

You can pass a numeric value into this function that represents a character. This character is then returned by this function. So passing 11167 will return the UP arrow, and 11165 the DOWN arrow.


In this case, I want to compare the selected year casualties against the number of casualties in the preceding year. Is it less? Then I want to show a green arrow pointing downwards. Is it more? Then show a red arrow pointing upwards.

Underneath is the measure I came up with. "_Down" contains the arrow pointing down, and "_Up" the arrow pointing up. "_return" in the end is where we return the up, or down, arrow, depending on whether the number of casualties in the selected ([aantalDoodType]) is more or less than the number of casualties the preceding year ([aantalDoodType-1Y]).

 
 

Ok, so now we have an arrow pointing up or down. We can use this measure in a KPI card. But now we want to give it a color. And I promise you. That's not too hard also...

Just go to the "visual properties" of the KPI card and select the "fx" button behind the color for the data label.


With this button, you can conditionally assign a color to the data label. For this to work, I created a measure that contains the difference between "the number of casualties in the preceding year and in the selected year":





This measure is then used in the conditional formatting options of the KPI card.

So, as you can see above, if [aantalDoodVerschil] >= 0, then color green, and if [aantalDoodVerschil] <= 0, then color red. As easy as it can be ;)


Of course, you have to adjust these to your own circumstances, and you can add a more diverse color pallet, or different UNICODE characters. But the idea stays the same. Find a character that matches your story, place it in a KPI card, color it, and place it on top of another KPI card.

There it is, your own custom KPI card.


Let me know, was this helpful for you? Did you find any interesting unicode characters? Or do you have another trick to make KPI cards more insightful?


Thanks for reading!


16 weergaven
bottom of page