Create a new table called, “_GUI Measures” with a Blank Query. This will be a dummy table, so that we can group our measures in one place.
Click Close and Apply to close the Power Query window.
In the Power BI Desktop screen
Change the data classification of the ImageURL column to Image URL
Change the data classification of the WebURL column to Web URL
Set default summarization of Images.ImageId to Maximize.
Ensure there is a bi-directional relationship between the two tables on ImageId.
7. Create a new Measure called Tag Measure under “_GUI_Measures”
Tag Measure = IF(
//Is the Tag Column filtered?
// True in Matrix Visual when row is expanded, and False when row is collapsed.
,//value to show in Expanded (detail) Mode in Matrix Visual when there is a Tag Value
,//value to show in Collapsed (Summary) Mode
//simple comment and uncomment one of the following for desired behaviour.
//Show Single Tag value associated to the MAX Confidence for the ImageId
CALCULATE(MAX(ImageTags_VisionInsight[Tag]), FILTER(ImageTags_VisionInsight, ImageTags_VisionInsight[Confidence] = MAX(ImageTags_VisionInsight[Confidence]) ))
//Show All Tag values comma-separated associated to the MAX Confidence
//MAX(ImageTags_VisionInsight[Tags] ) //Summary comma seperated Tag Values for SubTotal
Formula Explanation: The ISFILTERED function is used to determine if the Tag column is being filtered directly.
When the matrix visual is expanded state then the Tag column has values and has a filter context so the function will return TRUE, but when the matrix visual is in collapsed state there is no filter context being applied on the Tag column so the function will return FALSE.
When the matrix visual is in expanded state then we want to display the Tag value, since this is a measure will use the MAX() aggregate. This will basically do a MAX of a single row, which is return the same value as the column value.
When the row in the matrix visual is in collapsed state then we have two options of how we want to display the value:
Display all tag values comma-separated. Which means, it makes more sense to not display value in the confidence cell.
Since this is a measure, we are using MAX. If you want this behaviour, then uncomment this line and then comment out the CALCULATE line.
b. Display the maximum confidence, and then display the Tag corresponding to the maximum confidence.
There is a relationship between the Images table and the ImageTags_VisionInsight table on the ImageId column. Using the CALCULATE function we can retrieve the Tag value by filtering confidence value to match the MAX confidence value for that ImageId.
8. Create a new Measure called Confidence Measure under “_GUI_Measures”.
Confidence Measure = /*This uses the SWITCH instead of Nested IF statements*/
//If Tag is filtered, then it is a single Tag Value in Expanded Mode, so return the Confidence value.
//If Tag Measure has comma-separated value then we are in Collapse Mode, so return blank.
//If Tag Measure is blank return blank.
, //else this means we are showing a Single tag in Expanded Detail Mode, So simple return Confidence %
9. Set the Folder location and Percentage format for the Confidence Measure.
10. Similarly set the folder for the Tag Measure to Visual Insights.
We created DAX measures to control what is displayed as the Tag and the Confidence Value when a row is in collapsed (summarized) mode in a Matrix Visual. In the next post we will use these measures in the Matrix Visual.