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...
  • 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.