Hi @Dharma,
Thank you very much for posting your query in the forum.
To ensure that when displaying the hierarchy by Product and SalesPeople, Products with a Blank value do not appear, I have created the following measures:
TopX Sales by Product =
VAR _TopX =
SELECTEDVALUE( 'Rank Values'[Rank No] )
VAR _Product_Rank = SUMX(
ADDCOLUMNS(
SUMMARIZE( Sales, Products[Product Name] ),
"@Product Name", RANKX(
ALL( Products[Product Name] ),
[Total Sales],,
DESC
)
),
[@Product Name]
)
VAR _Result = IF(
_Product_Rank <= _TopX,
[Total Sales],
BLANK()
)
RETURN
_Result
TopX Sales by SalesPeople =
VAR _TopX =
SELECTEDVALUE( 'Rank Values'[Rank No] )
VAR SalesPeople_Rank = SUMX(
ADDCOLUMNS(
SUMMARIZE( Sales, Salespeople[Salesperson Name] ),
"@SalesPerson Name", RANKX(
ALL( Salespeople[Salesperson Name] ),
[Total Sales],,
DESC
)
),
[@SalesPerson Name]
)
VAR _Result = IF(
SalesPeople_Rank <= _TopX,
[Total Sales],
BLANK()
)
RETURN
_Result
Rank Test =
VAR _TopX =
SELECTEDVALUE( 'Rank Values'[Rank No] )
VAR _Product_Rank = CALCULATE(
[TopX Sales by Product],
ALL( Salespeople[Salesperson Name] )
)
VAR _Dynamic_SalesPerson = IF(
HASONEVALUE( Products[Product Name] ) &&
HASONEVALUE( Salespeople[Salesperson Name] ),
IF(
NOT ISBLANK( _Product_Rank ),
[TopX Sales by SalesPeople],
BLANK()
),
[TopX Sales by SalesPeople]
)
VAR _Result = SWITCH(
TRUE(),
ISINSCOPE( Salespeople[Salesperson Name] ),
_Dynamic_SalesPerson,
ISINSCOPE( Products[Product Name] ),
[TopX Sales by Product],
BLANK()
)
RETURN
_Result
When we are showing the hierarchy by Product and SalesPeople, we show the ranking for the Salespeople when the Product ranking is not blank.
I hope it can be of help to you.
Regards
Customer attrition_JAFP.pbix (445.1 KB)