0

I'm attempting to create a measure to give me the rank of a Salesman by Sales. I'll use the measure in a table where one of the columns is Salesman, so there should be the appropriate row context applied. But using RETURN Calculate( MAXX (RankTable, [Rank] ) ) just gives me a value of 1 for every broker. I can't figure out what to used to just pull out the value for Rank calculated in RankTable. How do I do that?

SumSales = sumx( SalesData, [Sale])
----------
SalesRank = 
VAR SummaryTable = 
    ADDCOLUMNS(
        SUMMARIZE( SalesData, [Salesman] ),
        "Sales", [SumSales]
    )   
VAR RankTable = 
    ADDCOLUMNS(
        SummaryTable,
        "Rank", RANKX( SummaryTable, [Sales])
    )
RETURN 
    Calculate( MAXX (RankTable, [Rank] ) )

I know that RankTable is correct, since DAX Studio give me this result:

Salesman Sales Rank

A 907 1

B 600 3

C 900 2

D 500 4

Here's code for measure mentioned in comments:

Priced. = 
COUNTROWS(
    FILTER( 'Cases',
        [Date Initiated] >= [MinDate]
        && [Date Initiated] <= [MaxDate]
        && not ISBLANK( [Date To Pricing] )
    )
)

1 Answer 1

1

I think you might be overcomplicating things, this should work:

SalesRank = RANKX(ALL('Salesdata'[Salesman]), [SumSales])

Reason you're getting 1 for every line is because in a visual the measure is calculated in the context containing a single salesman. So you need to remove this filter using the ALL() function.

Sign up to request clarification or add additional context in comments.

4 Comments

Yep, that works fine! I've been working with DAX for about a year now, and it never fails: When something isn't working, the solution always involves simplifying the code, not adding to it.
BTW, I still wonder how I would finish off the original code.
Hmm, the SalesData example was just a small table for testing this. I tried to extend this to the actual production situation. I used Top Priced Rank. = RANKX( ALL( 'Cases'[Broker] ), [Priced.] ) -- and every entry in the table is again 1. The definition for [Priced.] is in the original answer above. I don't see anything that's different from the simpler example. Any idea why I'm again getting all 1's again?
Just drop the column name i.e. [Broker] and remove filters from the entire table: RANKX( ALL( 'Cases' ), [Priced] )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.