Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rajasekar_o
Helper III
Helper III

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

rajasekar_o_0-1714477789287.png

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 

 

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

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] )

vbinbinyumsft_0-1714530597875.png

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.

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

How have you arrived at those number?

Ashish_Mathur_0-1714534514228.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-binbinyu-msft
Community Support
Community Support

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] )

vbinbinyumsft_0-1714530597875.png

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.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.