In the Power Query screen
In the Power BI Desktop screen
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.
ISFILTERED( ImageTags_VisionInsight[Tag])
,//value to show in Expanded (detail) Mode in Matrix Visual when there is a Tag Value
MAX(ImageTags_VisionInsight[Tag]) //Detail
,//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:
//MAX(ImageTags_VisionInsight[Tags])
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.
OR
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*/
SWITCH(TRUE()
//If Tag is filtered, then it is a single Tag Value in Expanded Mode, so return the Confidence value.
,ISFILTERED( ImageTags_VisionInsight[Tag])
,MAX(ImageTags_VisionInsight[Confidence])
//If Tag Measure has comma-separated value then we are in Collapse Mode, so return blank.
,CONTAINSSTRING([Tag Measure],",")
,BLANK()
//If Tag Measure is blank return blank.
,ISBLANK([Tag Measure])
,BLANK()
, //else this means we are showing a Single tag in Expanded Detail Mode, So simple return Confidence %
MAX(ImageTags_VisionInsight[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.
Summary
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.