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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
tareknasifbi
New Member

How to get top 1 brand with dax

I need to show No 1 Brand which has most sales value. For this I am making a measure where brands are ranked and then I am selecting one brand using TOP N (1) . The measure is giving accurate result most of the time but sometimes it it giving 2 numbers. But its not consistent. How to get rid of the issue. My measures are as follows,

 

Top Most Customer =

VAR pers =

    SELECTEDVALUE ( 'Perspective Dim'[Perspective] )

RETURN

    CONCATENATEX (

        CALCULATETABLE (

            TOPN (

                1,

                FILTER (

                    ALL ( 'Customer Dim'[CONSOLIDATED_GROUP_NAME] ),

                    NOT ( ISBLANK ( 'Customer Dim'[CONSOLIDATED_GROUP_NAME] ) )

                        && NOT ( ISBLANK ( [vs LY] ) )

                ),

                [CustomerRankDesc], ASC

            )

        ),

        'Customer Dim'[CONSOLIDATED_GROUP_NAME] & "(" & [vs LY Formatted] & ")",

        ", "

    )

=====================================================================
CustomerRankDesc =

VAR CustomerName =

    SELECTEDVALUE ( 'Customer Dim'[CONSOLIDATED_GROUP_NAME] )

RETURN

    IF (

        NOT ( ISBLANK ( [Total Value] ) ) && NOT ( ISBLANK ( CustomerName ) ),

        RANKX ( ALL ( 'Customer Dim'[CONSOLIDATED_GROUP_NAME] ), [vs LY],, DESC, DENSE )

    )

=====================================================================

vs LY =

DIVIDE ( ( [Selected Perspective] - [LY] ), [LY], 0 )

1 REPLY 1
tamerj1
Super User
Super User

Hi @tareknasifbi 

please try

Top Most Customer =

VAR pers =

    SELECTEDVALUE ( 'Perspective Dim'[Perspective] )

RETURN

    CONCATENATEX (

        CALCULATETABLE (

            TOPN (

                1,

                FILTER (

                    ALL ( 'Customer Dim'[CONSOLIDATED_GROUP_NAME] ),

                    NOT ( ISBLANK ( 'Customer Dim'[CONSOLIDATED_GROUP_NAME] ) )

                ),

                [vs LY]

            )

        ),

        'Customer Dim'[CONSOLIDATED_GROUP_NAME] & "(" & [vs LY Formatted] & ")",

        ", "

    )

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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