PowerBI.tips

Measures – Intelligent Card Visual – Using DAX

July 28, 2016 By Mike Carlo
Measures – Intelligent Card Visual – Using DAX

As I have been exploring PowerBI and building dashboards I have noticed that often the visuals can obscure your data. As you click on different visuals there is a need to highlight different pieces of data.

Sample Visual Example

Notice the different car types in the bar chart. As you click on each vehicle type, Diesel, Hatchback, etc.. you expect the data to change accordingly. In some cases it is helpful to present a card visual to show the user what you selected and any relevant data points you want to highlight. For example if I select the Diesel vehicle type I may want to know the average sales amount, total sales in dollars, or number of units sold. This is where we can build specific measures that will intelligently highlight selected data within your PowerBI visual.

Entering the Sample Data

Let’s begin with starting with some data. In honor of your news feed being bombarded with Pokemon Go articles lets enter some data on Pokemon characters.

We will enter our data manually. For a full tutorial on manually entering in data visit here.

Click the Enter Data button on the Home ribbon and enter the following information into the displayed table.

PokemonXP
Pikachu1200
Weedle650
Pidgey800
Golbat300

Rename the table to Characters. Once you are finished entering in the data it should look like the following:

Create Table of Characters

Click Load to continue.

Building the Basic Visuals

Start to examine your data by building a table visual.

Table Visual

Next add a Bar chart.

Bar Chart

Note: I added the XP column twice. Once to the Value attribute and to the Color Saturation. This enhances the look of your visual by coloring the bars with a gradient. The largest bar will have the darkest color, and the smallest bar will have the lightest color.

Creating the Total XP Measure

Next, we will begin building some measures. The first measure will be a total of all the experience points (XP) for each character. Click the New Measure button on the Home ribbon and enter the following DAX expression:

Total XP = Sum(Characters[XP])

Now, add a Card visual and add the new measure we created Total XP.

Total XP Card Visual

This measure totals all the experience points for all the selected characters within the visual. Since all characters are now selected the total XP for all characters is 2,950.

Creating the Intelligent Card Measure

The next, and final measure, will be the intelligent card. For this measure we want to display the character’s name when we select them in the bar chart. Click the New Measure button on the Home ribbon and enter the following DAX expression:

Character(s) = IF( DISTINCTCOUNT(Characters[Pokemon]) = 1 , FIRSTNONBLANK('Characters'[Pokemon],'Characters'[Pokemon]) , DISTINCTCOUNT('Characters'[Pokemon]) & " Selected")

Update: As of Mid 2017 Microsoft introduced a new DAX expression called SELECTEDVALUE which greatly simplifies this equation. Below is an example of how you would change the DAX equation to use SELECTEDVALUE.

Selected = SELECTEDVALUE( Characters[Pokemon], DISTINCTCOUNT( Characters[Pokemon] ) & " Selected" )

Explanation of this Measure

This measure first checks to see how many distinct items are in the column Pokemon of our dataset. If there is only one selected character then we will display the FIRSTNONBLANK character, which will be the name of our selected character. If there are more than one characters selected, the measure will count the number of characters selected and return a text string with the count and the word Selected. Thus, showing us how many items have been selected.

Testing the Intelligent Card

Add the measure titled Character(s) to a card visual.

Add Character Card Visual

We can now see that there are 4 characters selected. Clicking on Pikachu in the bar chart resolves with the character’s name being displayed and the XP of Pikachu being displayed in the Total XP card visual.

Selecting Pikachu

You can select multiple items by holding down Ctrl and clicking multiple items in the bar chart.

Selecting Pikachu and Pidgey

Well, that is it. I hope you enjoyed this Pokemon themed tutorial. Thanks for visiting.

Previous

Measures – Month to Month Percent Change

More Posts

Oct 6, 2026

Where Writeback Belongs – Ep.569

An anonymous mailbag asks whether Power BI should let people act on a number without leaving the report. Tommy Puglia and Mike Carlo put writeback in Fabric apps, keep the report for consumption, and treat translytical task flows as the exception.

Oct 1, 2026

FabCon Barcelona - Feature Draft – Ep.568

Tommy Puglia and Mike Carlo draft a team from the FabCon Barcelona feature list, starting with Fabric app backends and the ontology authoring agent. The picks that follow are pay-as-you-go capacity, the Fabric notebook toolkit, deployment hooks, and text search in semantic models.

Sep 29, 2026

The Right Model for the Task – Ep.567

Tommy Puglia and Mike Carlo use Kurt Buhler and Eugene Meidinger's Tabular Editor piece to decide which model and effort level belongs on a Fabric task. The same hour covers FabCon Barcelona's Fabric app backend, semantic views, and why monthly active agents may matter more than monthly active users.