Hi @acnyc88,
Thanks for supplying a PBIX and Data source file
I’ve added a FileLocation parameter, you can select your location from the list to restore all queries.
The data source contained a NULL row in the Dates table, preventing validation by “mark as date table” - so I removed that.
Created a New Table to include a “Both” row
Added that to the model
And created this measure for the count:
No of PartnerIDs =
VAR _SelVal = SELECTEDVALUE( 'Prod Type'[Type] )
VAR _TableA = CALCULATETABLE( VALUES( Transactions[PartnerID] ), 'Prod Type'[Type] = "A", REMOVEFILTERS( 'Prod Type' ))
VAR _TableB = CALCULATETABLE( VALUES( Transactions[PartnerID] ), 'Prod Type'[Type] = "B", REMOVEFILTERS( 'Prod Type' ))
VAR _Both = COUNTROWS( INTERSECT( _TableA, _TableB ))
RETURN
SWITCH( _SelVal,
"A", COUNTROWS( _TableA ) - _Both,
"B", COUNTROWS( _TableB ) - _Both,
"Both", _Both,
COUNTROWS( VALUES( Transactions[PartnerID] ))
)
And this one for the Total Sales:
TotalSales PartnerIDs =
VAR _SelVal = SELECTEDVALUE( 'Prod Type'[Type] )
VAR _TableA = CALCULATETABLE( VALUES( Transactions[PartnerID] ), 'Prod Type'[Type] = "A", REMOVEFILTERS( 'Prod Type' ))
VAR _TableB = CALCULATETABLE( VALUES( Transactions[PartnerID] ), 'Prod Type'[Type] = "B", REMOVEFILTERS( 'Prod Type' ))
RETURN
SWITCH( _SelVal,
"A", SUMX( ADDCOLUMNS( EXCEPT( _TableA, _TableB ), "Sales", [Sales] ), [Sales] ),
"B", SUMX( ADDCOLUMNS( EXCEPT( _TableB, _TableA ), "Sales", [Sales] ), [Sales] ),
"Both", CALCULATE( [Sales], INTERSECT( _TableA, _TableB ), ALL( 'Prod Type' )),
CALCULATE( [Sales], ALLSELECTED( Transactions ))
)
With this result.
Note. If required you can ‘hide’ the Group column by disabeling word wrap and minimizing the column width, so it’s no longer visible.
.
Here’s your sample file
Segment Analysis.pbix (343.9 KB)
I hope this is helplful.