With the expected result in place I propose the following measures. One to count the distinct unvisited chemists for the selected salesman/salesmen:
Unvisited Chemists :=
VAR _customerCount = CALCULATE ( DISTINCTCOUNTNOBLANK ( 'Source Data'[CustomerNameFull] ) , ALLSELECTED ( Dates ) )
VAR _visitedCount = [Customer Count]
RETURN _customerCount - _visitedCount
And one to format the matrix:
Customer Count w/ Unvisited =
IF ( [Customer Count] <> BLANK () ,
SWITCH (
TRUE (),
NOT ISINSCOPE ( 'Source Data'[CustomerNameFull] ) && ISINSCOPE ( Dates[Month] ) ,
[Customer Count] & " (" & [Unvisited Chemists] & ")" ,
FORMAT ( [Customer Count] , "#" )
)
)
Please note that here I am using a date table instead of using auto date/time on the INVDATE
column. This is considered best practice anyway. Remember to set the correct sort column, see guide here: https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-sort-by-column
I have used a simple date table:
Dates =
ADDCOLUMNS (
CALENDARAUTO () ,
"Year" , YEAR ( [Date] ) ,
"MonthNo" , MONTH ( [Date] ) ,
"Month" , FORMAT ( [Date] , "MMMM" )
)
The data model looks like this:
The result looks like this:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…