powerpivot - Rank Values of one column by filtering on 2nd column in DAX -


i'm trying use rankx formula rank values of 1 column, filtered value of second column. in example, col2 simple counter running in ascending value. i'm trying find item_id's rank value relative col1.

col1    col2 1001    8001 1001    8002 1002    8003 1002    8004 1002    8005 

i'd figure out col3 read:

col1    col2    col3 1001    8001    1 1001    8002    2 1002    8003    1 1002    8004    2 1002    8005    3 

because rank of col2 relative col1.

you don't need use rankx @ all. see section on earlier in superb http://www.daxpatterns.com/. add new calculated column in table:

= countrows (     filter (         mytable,         [col2] <= earlier ( [col2] )             && [col1] = earlier ( [col1] )     ) ) 

if want use rankx can adapt formula follows:

= rankx (     filter ( mytable, [col1] >= earlier ( [col1] ) ),     [col2],     ,     1 ) 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -