Forum Discussion

rajasekar_o's avatar
rajasekar_o
Icon for Helper V rankHelper V
2 years ago
Solved

Top 2 sales

hi team,
i have the sales data 
I  Want to  calculate
1.ASO top 2 sales based on  top2 target value  the top 2 target is take only if t20 is 'Y'
2.ASM top 2 sales based on  top2 target value  the top 2 target is take only if t20 is 'Y'
3.BM top 2 sales based on  top2 target value  the top 2 target is take only if t20 is 'Y'

DEALERCODEASO CODEASM CODEBM CODEsalesTARGETt20
DEALE-01ASO-01ASM-01BM-013898839000Y
DEALE-02ASO-01ASM-01BM-0134883500Y
DEALE-03ASO-01ASM-01BM-0144884500 
DEALE-04ASO-01ASM-01BM-0175887600Y
DEALE-05ASO-01ASM-01BM-0134883500 
DEALE-06ASO-02ASM-01BM-011208812100 
DEALE-07ASO-02ASM-01BM-011108811100Y
DEALE-08ASO-02ASM-01BM-011558815600Y
DEALE-09ASO-02ASM-01BM-012318823200Y
DEALE-10ASO-02ASM-01BM-012668826700 
DEALE-11ASO-03ASM-02BM-013878838800Y
DEALE-12ASO-03ASM-02BM-014988849900Y
DEALE-13ASO-03ASM-02BM-011208812100Y
DEALE-14ASO-03ASM-02BM-011254812560 
DEALE-15ASO-03ASM-02BM-011638816400 
DEALE-16ASO-04ASM-02BM-011830818320 
DEALE-17ASO-04ASM-02BM-012143821450 
DEALE-18ASO-04ASM-02BM-013118831200Y
DEALE-19ASO-04ASM-02BM-014498845000Y
DEALE-20ASO-04ASM-02BM-0164886500Y

 


THE FINAL OUT PUT 
ASO TOP 2 SALES =261304
ASM TOP 2 SALES=157052
BM TOP 2 SALES =81076

i try calculation for ASO TOP 2 SALES ,ASM TOP 2 SALES,BM TOP 2 SALES  its show same value for all.
how to calculate this 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi rajasekar_o ,

    Please try to create measure with below dax formula:

    ASM TOP2 =
    VAR tmp =
        FILTER ( 'Table', [t20] = "Y" )
    VAR tmp1 =
        ADDCOLUMNS (
            tmp,
            "RK", RANK (, tmp, ORDERBY ( [sales], DESC ), PARTITIONBY ( 'Table'[ASM CODE] ) )
        )
    VAR tmp2 =
        FILTER ( tmp1, [RK] IN { 1, 2 } )
    RETURN
        SUMX ( tmp2, [sales] )
    
    ASO TOP2 =
    VAR tmp =
        FILTER ( 'Table', [t20] = "Y" )
    VAR tmp1 =
        ADDCOLUMNS (
            tmp,
            "RK", RANK (, tmp, ORDERBY ( [sales], DESC ), PARTITIONBY ( 'Table'[ASO CODE] ) )
        )
    VAR tmp2 =
        FILTER ( tmp1, [RK] IN { 1, 2 } )
    RETURN
        SUMX ( tmp2, [sales] )
    
    BM T2 =
    VAR tmp =
        FILTER ( 'Table', [t20] = "Y" )
    VAR tmp1 =
        ADDCOLUMNS (
            tmp,
            "RK", RANK (, tmp, ORDERBY ( [sales], DESC ), PARTITIONBY ( 'Table'[BM CODE] ) )
        )
    VAR tmp2 =
        FILTER ( tmp1, [RK] IN { 1, 2 } )
    RETURN
        SUMX ( tmp2, [sales] )
    

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_Binbin Yu
    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 rajasekar_o ,

    Please try to create measure with below dax formula:

    ASM TOP2 =
    VAR tmp =
        FILTER ( 'Table', [t20] = "Y" )
    VAR tmp1 =
        ADDCOLUMNS (
            tmp,
            "RK", RANK (, tmp, ORDERBY ( [sales], DESC ), PARTITIONBY ( 'Table'[ASM CODE] ) )
        )
    VAR tmp2 =
        FILTER ( tmp1, [RK] IN { 1, 2 } )
    RETURN
        SUMX ( tmp2, [sales] )
    
    ASO TOP2 =
    VAR tmp =
        FILTER ( 'Table', [t20] = "Y" )
    VAR tmp1 =
        ADDCOLUMNS (
            tmp,
            "RK", RANK (, tmp, ORDERBY ( [sales], DESC ), PARTITIONBY ( 'Table'[ASO CODE] ) )
        )
    VAR tmp2 =
        FILTER ( tmp1, [RK] IN { 1, 2 } )
    RETURN
        SUMX ( tmp2, [sales] )
    
    BM T2 =
    VAR tmp =
        FILTER ( 'Table', [t20] = "Y" )
    VAR tmp1 =
        ADDCOLUMNS (
            tmp,
            "RK", RANK (, tmp, ORDERBY ( [sales], DESC ), PARTITIONBY ( 'Table'[BM CODE] ) )
        )
    VAR tmp2 =
        FILTER ( tmp1, [RK] IN { 1, 2 } )
    RETURN
        SUMX ( tmp2, [sales] )
    

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.