From the course: Power BI Weekly
Display the top of a symmetric matrix - Power BI Tutorial
From the course: Power BI Weekly
Display the top of a symmetric matrix
- [Instructor] If we create a symmetrical matrix in Power BI or any other tool, the top part of the matrix is the exact same as the bottom part, but transposed along the axis that runs through the middle. We can see this in our distance calculation examples between the origin and destination pairs. It doesn't matter what order that the order or destination go in. We can actually reverse the destination and origin and get the same numbers. Let's use this logic to only display the top part of the matrix. Notice that we're adding the combination of rows and columns together to pair them up within our matrix view. For this example, to only see the top part of the matrix, this is a calculation group. So we're going to modify the formula for the calculation item associated with this calculation group. We can do this by navigating to the Model view to make our changes. We're going to expand some of the levels. If you're going back into the calculation group, you want to expand each of these levels until you reach the calculation item that you want to edit. We'll then click into our calculation item formula. We're going to set our current result equal to the VAR result. I'm also going to calculate another part of this formula that's going to use the MAX to reference, we're going to call this city_label, and we'll refer to the MAX of the City Coordinates. We can then update a result formula to use the city_label to make it a bit more efficient. Now we need to add another return statement that actually returns the results of our calculation item. We'll set this up using IF conditional logic. So we want to use the alphabetical order of the labels as a way to sort them. So I'm going to refer to the selected measure name by using its eponymous function. And we use these selected measure names in different, more limited docs formulas, but where we can use them are often very impactful. So we want to say the SELECTEDMEASURENAME is greater than or equal to our city_label, that is we already calculated within this formula, then we'll return the result, otherwise we'll return a blank. So what we're doing here is we're saying that if the name of our measure, which is the city that is the destination, comes after the city_label within our result, we want to essentially use this to control which part of the matrix we see. Let's confirm our calculations, and we'll navigate back to our Report view. So now we only see the top part of the matrix. What we've done here is we've removed duplicated pairs of cities that we're calculating the distances between. We can also display only the bottom part by changing the inequality and the return statement to go the other way. We'll say less than or equal to the city_label. And now what we see here is that if this label comes after the city name in the column, it will display the distance, otherwise it returns a blank. So we flipped the way that the symmetrical matrix appears. This often comes down to personal preference, and I actually like to see all the combinations of the calculations between different pairs, but sometimes being able to pair it down will make it easier to read, especially when we're looking at a symmetrical matrix with as many cities in this example.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
- Data_Sources.zip
- 15_06_begin.zip
- 15_05_begin.zip
- 15_04_begin.zip
- 15_03_begin.zip
- 15_02_begin.zip
- 15_01_begin.zip
- 14_13_begin.zip
- 14_12_begin.zip
- 14_11_begin.zip
- 14_10_begin.zip
- 14_09_begin.zip
- 14_08_begin.zip
- 14_07_begin.zip
- 14_06_begin.zip
- 14_05_begin.zip
- 14_04_begin.zip
- 14_03_begin.zip
- 14_02_begin.zip
- 14_01_begin.zip
- 13_13_begin.zip
- 13_12_begin.zip
- 13_10_begin.zip
- 13_09_begin.zip
- 13_08_begin.zip
- 13_07_begin.zip
- 13_06_begin.zip
- 13_05_begin.zip
- 13_04_end.zip
- 13_03_begin.zip
- 13_02_begin.zip
- 13_01_begin.zip
- 12_13_begin.zip
- 12_12_begin.zip
- 12_11_begin.zip
- 12_10_begin.zip
- 12_09_begin.zip
- 12_08_begin.zip
- 12_07_begin.zip
- 12_06_begin.zip
- 12_05_begin.zip
- 12_04_begin.zip
- 12_03_begin.zip
- 12_02_begin.zip
- 12_01_begin.zip
- 11_13_begin.zip
- 11_12_end.zip
- 11_11_begin.zip
- 11_10_begin.zip
- 11_09_begin.zip
- 11_08_begin.zip
- 11_07_begin.zip
- 11_06_begin.zip
- 11_05_begin.zip
- 11_04_begin.zip
- 11_03_begin.zip
- 11_02_begin.zip
- 11_01_begin.zip
- 10_13_begin.zip
- 10_12_begin.zip
- 10_11_begin.zip
- 10_10_begin.zip
- 10_09_begin.zip
- 10_08_begin.zip
- 10_07_end.zip
- 10_06_begin.zip
- 10_05_begin.zip
- 10_04_begin.zip
- 10_03_begin.zip
- 10_02_begin.zip
- 10_01_begin.zip
- 09_13_begin.zip
- 09_12_begin.zip
- 09_11_begin.zip
- 09_10_begin.zip
- 09_09_begin.zip
- 09_08_begin.zip
- 09_07_begin.zip
- 09_06_end.zip
- 09_05_begin.zip
- 09_04_begin.zip
- 09_03_begin.zip
- 09_02_begin.zip
- 09_01_begin.zip
- 08_13_begin.zip
- 08_12_begin.zip
- 08_11_begin.zip
- 08_10_begin.zip
- 08_09_begin.zip
- 08_08_begin.zip
- 08_07_begin.zip
- 08_06_begin.zip
- 08_05_begin.zip
- 08_04_begin.zip
- 08_03_begin.zip
- 08_02_begin.zip
- 08_01_begin.zip
- 07_13_begin.zip
- 07_11_begin.zip
- 07_10_begin.zip
- 07_09_begin.zip
- 07_08_begin.zip
- 07_07_begin.zip
- 07_06_begin.zip
- 07_05_begin.zip
- 07_04_begin.zip
- 07_03_begin.zip
- 07_02_begin.zip
- 07_01_begin.zip
- 06_13_begin.zip
- 06_12_begin.zip
- 06_11_begin.zip
- 06_10_begin.zip
- 06_09_begin.zip
- 06_08_begin.zip
- 06_07_begin.zip
- 06_06_begin.zip
- 06_05_begin.zip
- 06_04_begin.zip
- 06_03_begin.zip
- 06_02_begin.zip
- 06_01_begin.zip
- 05_13_begin.zip
- 05_12_begin.zip
- 05_11_begin.zip
- 05_10_begin.zip
- 05_09_begin.zip
- 05_08_begin.zip
- 05_07_begin.zip
- 05_06_begin.zip
- 05_05_begin.zip
- 05_04_begin.zip
- 05_03_begin.zip
- 05_02_begin.zip
- 05_01_begin.zip
- 04_13_begin.zip
- 04_12_begin.zip
- 04_11_begin.zip
- 04_10_begin.zip
- 04_09_begin.zip
- 04_08_begin.zip
- 04_07_begin.zip
- 04_06_begin.zip
- 04_05_begin.zip
- 04_04_begin.zip
- 04_03_begin.zip
- 04_02_begin.zip
- 04_01_begin.zip
- 03_13_begin.zip
- 03_12_begin.zip
- 03_11_begin.zip
- 03_10_begin.zip
- 03_09_begin.zip
- 03_08_begin.zip
- 03_07_begin.zip
- 03_06_begin.zip
- 03_05_begin.zip
- 03_04_begin.zip
- 03_03_begin.zip
- 03_02_begin.zip
- 03_01_begin.zip
- 02_13_begin.zip
- 02_12_begin.zip
- 02_11_begin.zip
- 02_10_begin.zip
- 02_09_begin.zip
- 02_08_begin.zip
- 02_07_begin.zip
- 02_06_begin.zip
- 02_05_begin.zip
- 02_04_begin.zip
- 02_03_begin.zip
- 02_02_begin.zip
- 02_01_begin.zip
- 01_13_begin.zip
- 01_12_begin.zip
- 01_11_begin.zip
- 01_10_begin.zip
- 01_09_begin.zip
- 01_08_begin.zip
- 01_07_begin.zip
- 01_06_begin.zip
- 01_05_begin.zip
- 01_04_begin.zip
- 01_03_begin.zip
- 01_02_begin.zip
- 01_01_begin.zip
- Installation_Reminder.zip