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
Wael03
Helper I
Helper I

Generating Row Number in Power BI Visualization

Hello ! 

I have a table displaying the top 20 company by total transaction amount as you can see :

Wael03_1-1681812449659.png

This table can change with filter such as the date or the country.

I would like to add a column in the left of the table to display the ranking. So basicaly 1 to 20 like this :

Wael03_2-1681812580836.png

 

Do you know how to do that ?

 

 

 

7 REPLIES 7
Wael03
Helper I
Helper I

The thing is that the row "total" is still here but the "total" id is not. So I added an else : 

Ranking =
IF (
    ISINSCOPE ( table[company] ),
    RANKX (
        ALLSELECTED ( table[company] ),
        CALCULATE ( SUM ( table[Tran Amount] ) )
    ), "Total"
)

Wael03_0-1681825876904.png

But as you can see the ranking is now decimal I don't know why

Wael03
Helper I
Helper I

Well it kinda worked but the "Total" disappeared : 

Wael03_0-1681825321240.png

Is there any way to add an "ELSE" statement to put the "Total" back ?

 

I think that will come back automatically if you add a column which gives a total, e.g. the sum of tran amount. Without any columns which give a meaningful total value the total row is automatically hidden.

Wael03
Helper I
Helper I

Ok so I've managed to make it work using this DAX command : 

Ranking =
RANKX ( ALLSELECTED ( table[company] ), CALCULATE ( SUM ( table[Tran Amount] ) ) )

Wael03_0-1681818795879.png

But as you can see the "Total" disappear for the "1" how can I use the DAX command only for the 20 first rows and not the total row ?

 

Ranking =
IF (
    ISINSCOPE ( table[company] ),
    RANKX (
        ALLSELECTED ( table[company] ),
        CALCULATE ( SUM ( table[Tran Amount] ) )
    )
)
Wael03
Helper I
Helper I

I've tried it but when I put table[company] i cannot choose "tran amount' as second parameter i can only pick company again

johnt75
Super User
Super User

Try

Ranking =
RANKX ( ALLSELECTED ( 'Table'[Company] ), [Tran Amount] )

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.

Top Solution Authors