Forum Discussion

nnouchi's avatar
nnouchi
Helper I
7 years ago
Solved

Ranking Cumulative Total

Greetings PBI Community,   I'm having issues with figuring out how to write a DAX formula that would calculate the rank of different part_numbers based off of their cumulative total.    This is m...
  • Anonymous's avatar
    Anonymous
    7 years ago

    I see what I did, the ALL needs to be ALL ( Table[column] ) not just ALL ( Table).  So using the Contoso DB:  

     

    We have colors on rows, so that is the inital filter context.  Have a measure to count the # of products from the products table.  So with colors on rows, we will get the amount of products filtered by the color.

     

    Base Measure:

    Total Products = COUNTROWS('Product')

    Rank Measure:

    RANK = 
    RANKX(
        ALL( 'Product'[Color]),
        [Total Products])

     

    Using ALLSELECTED will give a "local" rank vs. a "global" rank of using ALL:

    RANK Using AllSelect = 
    RANKX(
        ALLSELECTED( 'Product'[Color]),
        [Total Products])