excel - Creating a RANKX() calculated column which obeys filter context -


i doing analysis of our customers , have existing column 'ranks' number of orders each customer has placed date ordered. mean if customer has placed 4 orders on 4 different dates 'persistantordercount' column have show follows:

orderid | orderdate | customerid | persistantordercount

101 | 01/01/2015 | 1 | 1

102 | 01/02/2012 | 1 | 2

103 | 01/03/2015 | 1 | 3

104 | 01/04/2015 | 2 | 1

105 | 01/05/2015 | 3 | 1

106 | 01/06/2015 | 1 | 4

as can see in example customers orders ranked based on order date first order being 1 and, in case of customer '1', last order being 4.

the formula use is:

= rankx (     filter (         'dataset',         [customerid] = earlier ( [customerid] )     ),     [orderid],     [orderid],     1,     dense ) 

the ranking of orders not change using formula based on filters have selected.

what need similar column ranking based on filters have applied, in particular need able filter date. if example use same data have filtered months mar, apr, may, jun want see following:

orderid | orderdate | customerid | persistantordercount

103 | 01/03/2015 | 1 | 1

104 | 01/04/2015 | 2 | 1

105 | 01/05/2015 | 3 | 1

106 | 01/06/2015 | 1 | 2

note how order 103 , 106, ranked 3 , 4 respectively, ranked 1 , 2 because within selected date period customers first , second order.

can me this?

i have tried reorganising formula use calculate() idea of using context sensitive filters did not work. has been frustrating me appreciated.

thanks.

rather doing adding column, approach add measure each of fields need:

[persistantordercount]:=rankx(filter(all('dataset'),'dataset'[customerid]=max('dataset'[customerid])),firstdate('dataset'[orderdate]),,1,dense) 

and

[filteredordercount]:=rankx(filter(allselected('dataset'),'dataset'[customerid]=max('dataset'[customerid])),firstdate('dataset'[orderdate]),,1,dense) 

which gives following result unfiltered dataset: enter image description here

and result when select months march, april, may , june: enter image description here


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -