Forum Discussion

bo_afk's avatar
bo_afk
Post Patron
5 years ago

Using rank as filter

Hi,

I have a table below which shows the number of visits to a web site for each customer based on the channel. I've also created a measure to rank the channel for each customer (using RANKX).

What I want to do is count how many customers there are for each channel where rank is equal to 1.

Table with ranks:

CustomerChannelTotal visitsRank
APaid Search431
ADirect Load32
AEmail23
ANatural Search14
AReferring Sites05
BDirect Load261
BPaid Search52
BEmail03
BReferring Sites03
CPaid Search161
CDirect Load32
CNatural Search13
CReferring Sites13
DDirect Load21
DPaid Search12
EPaid Search41
EDirect Load12
EPaid Social12

Filter for where Rank = 1

CustomerChannelRank
APaid Search1
BDirect Load1
CPaid Search1
DDirect Load1
EPaid Search1

EXPECTED RESULT: Count number of customers per channel where rank = 1

ChannelCustomer Count
Paid Search3
Direct Load2

Can anyone help with how I can do this? When I tried this by putting the measure filter on the table (rank=1), only 'Paid search' appeared and I think this is because it has the highest total visits overall.

Thanks!

17 Replies

    • bo_afk's avatar
      bo_afk
      Post Patron

      Hi camargos88, thanks for your response.

      I did try to filter the visual but it didnt work for me. What formula did you use for Rank?

      I used the following:

      Rank = RANKX(ALL(Table[Channel]),[Total visits])
      where [Total visits] is a measure sum(visits)
      • camargos88's avatar
        camargos88
        Community Champion

        bo_afk ,

         

        Use this measure, so you don't need to filter the visual:

        _Rank Channel = 
        VAR _tbl = SUMMARIZE('Table', 'Table'[Channel], 'Table'[Customer], "Rank", RANKX(FILTER(ALL('Table'), 'Table'[Customer] = EARLIER('Table'[Customer])), CALCULATE(SUM('Table'[Total visits])),, DESC))
        RETURN COUNTX(FILTER(_tbl, [Rank] = 1), [_Rank])