Forum Discussion

Gryphon269's avatar
Gryphon269
Frequent Visitor
1 year ago
Solved

Rank Item in Rows, Location in Columns

Hello,

 

I am looking to get a rank for sales for by Item for each loction and a grand total rank in one matrix. 

my dataset looks like this:

DateLocationProductUnits Sold
8/1/2024Location 2Item 13.000
8/1/2024Location 1Item 12.000
8/1/2024Location 3Item 12.000
8/4/2024Location 2Item 22.000
8/3/2024Location 2Item 22.000
8/2/2024Location 2Item 22.000
8/4/2024Location 2Item 31.000
8/3/2024Location 3Item 31.000
8/3/2024Location 2Item 31.000
8/2/2024Location 1Item 31.000

I want a rank output into a matrix for the dates selected that ranks sales of an item for each location:

ProductLocation 1Location 2Location 3Total
Item 11211
Item 23132
Item 32323

 

So Item 1 in this example is the number 1 seller at Location 1 and Location 3,  number 2 at Location 2, and Number 1 Overall.

I know I can create a a rankx function for each location, I am trying to figure out if there is an easier or more straightforward solution.

 

 

Edit: rankx does work. my issue was I was pulling item name from a product table so there was no connection to location. Sorry for not fully clarifying my full dataset. Thank you for the solutions, as they are what pointed me to my mistake.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Gryphon269 ,
    You can use the following measure in VALUE in the matrix, which might accomplish what you need.

    Measure = 
    RANKX(
        ALL('Table'[Product]),CALCULATE(SUM('Table'[Units Sold])))

    I would be honored if my answer can solve your problem, if you have further questions, you can contact me at any time, I will receive a message after the first time to reply!

    Hope it helps!

     

    Best regards,
    Community Support Team_ Tom Shen

     

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

     

3 Replies

  • Irwan's avatar
    Irwan
    Super User

    hello Gryphon269 

     

    i think rankx has already easy and straightforward (it only require one DAX).

     

     

    Hope this will help.
    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Gryphon269 ,
    You can use the following measure in VALUE in the matrix, which might accomplish what you need.

    Measure = 
    RANKX(
        ALL('Table'[Product]),CALCULATE(SUM('Table'[Units Sold])))

    I would be honored if my answer can solve your problem, if you have further questions, you can contact me at any time, I will receive a message after the first time to reply!

    Hope it helps!

     

    Best regards,
    Community Support Team_ Tom Shen

     

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

     

  • Hi,

    I used these measures:

    US = SUM(Data[Units Sold])
    Rank = RANK(DENSE,ALL(Data[Product]),orderby([US],DESC))

    Hope this helps.