Forum Discussion

Jlbaenlo's avatar
Jlbaenlo
Frequent Visitor
5 years ago
Solved

TOP N issue

Hi, I have a visual "Table like" containing 

Product-Country, Sales, Switch, KPI1 (all those fields are coming from 1 table called SFA_BIAS)

Siwtch is a value = -1 or 1

and 1 filter applied on the visual on Switch (et's say 1) 

When I apply the TOPN 10 on Product-Country field based on Sales, I would expect to get the Top 10 Product-country based on Sales having Switch  = 1

the table shows no records, as if the TOPN 10 would apply on the full data behind (as the top 10 Product-Country sales without filtering have a switch = -1)

 

I have also tried with a Rank

RankSales = RANKX(
ALLSELECTED(SFA_BIAS),
CALCULATE(SUM(SFA_BIAS[SALES]))
)
The RankSales applies well to my selection
but when I filter on RankSales <=10 the table does not show me records
 
Could you please help me to understand what I am doing wrong,
 
Many thanks for your help,
JL

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Jlbaenlo ,

     

    My sample data is this.

    Product-CountrySalesSwitchKPI1

    JP111
    JP1012
    CN313
    CN414
    USA1215
    USA1516
    UK717
    UK818
    JP919
    JP4110
    CN111
    CN1612
    USA313
    USA1514
    UK1815
    UK916
    UK5-17
    JP6-18
    JP1-19
    CN2-110
    CN3-11
    USA4-12
    USA8-13
    UK8-11
    UK7-12
    JP2-13
    JP1-14
    CN3-15
    CN6-16
    USA5-17
    USA1-18
    UK9-19
    UK9-110

     

    You could try to create a measure.This measure is to sort switch=1 and switch=-1 respectively.

     

     

    Measure =
    VAR ran =
        RANKX (
            FILTER ( ALL ( 'SFA_BIAS' ), 'SFA_BIAS'[Switch] = MAX ( 'SFA_BIAS'[Switch] ) ),
            CALCULATE ( MAX ( 'SFA_BIAS'[Sales] ) ),
            ,
            ASC,
            SKIP
        )
    RETURN
        IF ( ran <= 10, 1, 0 )

     

     

     

    Put the measure into Filters and set it.

     

    The result is this.

     

     

    You can check more details form here.

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Jlbaenlo ,

     

    My sample data is this.

    Product-CountrySalesSwitchKPI1

    JP111
    JP1012
    CN313
    CN414
    USA1215
    USA1516
    UK717
    UK818
    JP919
    JP4110
    CN111
    CN1612
    USA313
    USA1514
    UK1815
    UK916
    UK5-17
    JP6-18
    JP1-19
    CN2-110
    CN3-11
    USA4-12
    USA8-13
    UK8-11
    UK7-12
    JP2-13
    JP1-14
    CN3-15
    CN6-16
    USA5-17
    USA1-18
    UK9-19
    UK9-110

     

    You could try to create a measure.This measure is to sort switch=1 and switch=-1 respectively.

     

     

    Measure =
    VAR ran =
        RANKX (
            FILTER ( ALL ( 'SFA_BIAS' ), 'SFA_BIAS'[Switch] = MAX ( 'SFA_BIAS'[Switch] ) ),
            CALCULATE ( MAX ( 'SFA_BIAS'[Sales] ) ),
            ,
            ASC,
            SKIP
        )
    RETURN
        IF ( ran <= 10, 1, 0 )

     

     

     

    Put the measure into Filters and set it.

     

    The result is this.

     

     

    You can check more details form here.

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.