Forum Discussion
Question about Rankx in Matrix table format
- 4 years ago
Hi leilei787
Here is the sample file with the solution https://www.dropbox.com/t/ic5uywEC976ZR0zmYou need to create two columns.
Total Amount = VAR CurrentCode = 'Table'[PrimaryGeoCode_c] VAR CurrentCodeTable = FILTER ( 'Table', 'Table'[PrimaryGeoCode_c] = CurrentCode ) VAR Results = SUMX ( CurrentCodeTable, 'Table'[ShippedUSDAmountNet] ) RETURN ResultsRanking = RANKX ( 'Table', 'Table'[Total Amount], , DESC, Dense )Then create your measure
Shipping Net = SUM ('Table'[ShippedUSDAmountNet] )I hope this satisfies your requirement. If so please consider marking this reply as "Accepted" solution. Thank you!
Hi Tamerj1
sorry for the confusion. below is a more realistic sample.
the goal is to rank territory that sold BF product ( And BF product only. i need to show BF3.0, 5.0 and 5.8 but no need to rank these sub-categories, rank still based on the total). so previous ask was still valid. now the problem is that the ranking also need to be dynamic if i select an individual month. For example, if i select Feb, the rank will be based on BF sales in Feb. If i select Jan to April, the rank will be based on BF sales from Jan to Apr....is it possible?
| PrimaryGeoCode_c | CurrencyCode | ShippedUSDAmountNet | ProductFamilyCode | Month |
| 1101 | USD | $ 34,342 | GVM | 1 |
| 1101 | USD | $ 5,332 | BF2.5 | 2 |
| 1101 | USD | $ 355 | BF3.8 | 2 |
| 1101 | USD | $ 3,556 | BBQ | 3 |
| 1101 | USD | $ 24,522 | BF5.0 | 4 |
| 1102 | USD | $ 3,456 | VGN | 1 |
| 1102 | USD | $ 7,445 | BF5.0 | 2 |
| 1102 | USD | $ 844 | BF3.8 | 2 |
| 1102 | USD | $ 985 | GVM | 3 |
| 1102 | USD | $ 8,980 | BF3.8 | 4 |
| 1103 | USD | $ 593 | VGN | 1 |
| 1103 | USD | $ 4,653 | BF3.8 | 2 |
| 1103 | USD | $ 3,353 | BF5.0 | 2 |
| 1103 | USD | $ 2,432 | GVM | 3 |
| 1103 | USD | $ 2,556 | BF3.8 | 4 |
| 1104 | USD | $ 4,342 | BF5.0 | 1 |
| 1104 | USD | $ 56,245 | BF3.8 | 2 |
| 1104 | USD | $ 9,543 | VGN | 2 |
| 1104 | USD | $ 29,405 | BBQ | 3 |
| 1104 | USD | $ 34,532 | BF5.0 | 4 |
Hi leilei787
In this case, it has to be a measure that is your first solution. Again we will have the problems of your original query hence back to square 1.
So I would advise to go back to your original measure and try to manually hide the ranking for subtotals by minimizing the respective column size to zero width with your mouse. Shifting the row grand total to the left is not possible.
Finally, you can filter out all product families other than "BF" by creating a new table using simple code
Table 2 =
FILTER (
'Table',
CONTAINSSTRING ( 'Table'[ProductFamilyCode], "BF" )
)
Then use the new table instead for your analysis.
Please let me know if anything further I can help you with.
Have a great day!