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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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