Forum Discussion
Top 10 RANKX with two columns and IF ?
- Anonymous2 years ago
Hi RasmusN532 ,
According to your description, I modified the formula. the Top10Customers parameter returns the table that satisfies the top10 condition, and the results are based on this table in the later conditional judgment.
Top10Customers1 = TOPN ( 10, SUMMARIZE ( 'YourTable', 'YourTable'[Customer Hierarchy 1], "TotalSales", CALCULATE ( MAX(YourTable[Net Sales]) ) ), [TotalSales], DESC )
You can refine this formula and apply it to the complete data model.Rank Customer = VAR Top10Customers = TOPN ( 10, SUMMARIZE ( 'YourTable', 'YourTable'[Customer Hierarchy 1], "TotalSales", CALCULATE ( MAX(YourTable[Net Sales]) ) ), [TotalSales], DESC ) RETURN IF ( ISINSCOPE ( 'YourTable'[Customer Hierarchy 1] ), RANKX ( Top10Customers, [TotalSales] ), IF ( ISINSCOPE ( 'YourTable'[Customer Hierarchy 2] ), RANKX ( FILTER ( Top10Customers, 'YourTable'[Customer Hierarchy 1] = BLANK () ), [TotalSales] ) ) )Best Regards,
Adamk KongIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi RasmusN532 ,
According to your description, I modified the formula. the Top10Customers parameter returns the table that satisfies the top10 condition, and the results are based on this table in the later conditional judgment.
Top10Customers1 =
TOPN (
10,
SUMMARIZE (
'YourTable',
'YourTable'[Customer Hierarchy 1],
"TotalSales", CALCULATE ( MAX(YourTable[Net Sales]) )
),
[TotalSales], DESC
)
You can refine this formula and apply it to the complete data model.
Rank Customer =
VAR Top10Customers =
TOPN (
10,
SUMMARIZE (
'YourTable',
'YourTable'[Customer Hierarchy 1],
"TotalSales", CALCULATE ( MAX(YourTable[Net Sales]) )
),
[TotalSales], DESC
)
RETURN
IF (
ISINSCOPE ( 'YourTable'[Customer Hierarchy 1] ),
RANKX ( Top10Customers, [TotalSales] ),
IF (
ISINSCOPE ( 'YourTable'[Customer Hierarchy 2] ),
RANKX (
FILTER (
Top10Customers,
'YourTable'[Customer Hierarchy 1] = BLANK ()
),
[TotalSales]
)
)
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for this!