Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to add row numbers to a table visual

Hi,

 

I have what seems to be a simple question:   Is there a way to add rows numbers to a table visual?

 

The table visual in question is populated by fields from multiple tables.  Also, I tried using the rank function but it takes soooo long to process for me...it's just not what I need.  

 

Is there any other way to accomplish this?  I want the table visual to populate with a 1 on row 1, 2 for row 2 and 3 for row 3 etc etc.  I'll be slicing and dicing the table visual by using slicers at the top of the page along with clicking on other visuals.

 

I'd like to add this "row count" to my MDC table below:

 

 

  • Dear Power BI aspirant, 

     

    How to Add a Row Number in a Power BI Desktop Table Visual? 

     

    SCENARIO:
    - You have added data from fields in your Table visual.

    - There are many (hundreds/thousands) of rows, but there is no number for each row. 

    - You want to add a number beside each row by adding a Number Column from your fields. 

    - You have not created any number columns as yet. 

     

    SOLUTION 

    - Create a New Measure

    - Input DAX Formula below

     

    DAX FORMULA

    Row_Number =
    CALCULATE (
    DISTINCTCOUNT(TABLE[COLUMN WHICH NEEDS ITS ROWS TO BE COUNTED]),
    FILTER(ALLSELECTED(TABLE), TABLE[COLUMN WHICH NEEDS ITS ROWS TO BE COUNTED] <= MAX(TABLE[COLUMN WHICH NEEDS ITS ROWS TO BE COUNTED]))
    )

     

    Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

     

4 Replies

  • Dear Power BI aspirant, 

     

    How to Add a Row Number in a Power BI Desktop Table Visual? 

     

    SCENARIO:
    - You have added data from fields in your Table visual.

    - There are many (hundreds/thousands) of rows, but there is no number for each row. 

    - You want to add a number beside each row by adding a Number Column from your fields. 

    - You have not created any number columns as yet. 

     

    SOLUTION 

    - Create a New Measure

    - Input DAX Formula below

     

    DAX FORMULA

    Row_Number =
    CALCULATE (
    DISTINCTCOUNT(TABLE[COLUMN WHICH NEEDS ITS ROWS TO BE COUNTED]),
    FILTER(ALLSELECTED(TABLE), TABLE[COLUMN WHICH NEEDS ITS ROWS TO BE COUNTED] <= MAX(TABLE[COLUMN WHICH NEEDS ITS ROWS TO BE COUNTED]))
    )

     

    Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

     

    • ejayarajan's avatar
      ejayarajan
      New Member

      My report uses the direct query method, I had tried multiple suggested methods online none worked finally it was your solution that was able to providve the row numbers insequence. Thank you Harisai

    • Weilun's avatar
      Weilun
      New Member

      Got a similar case and this method solves it perfectly, thanks!