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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
gtamir
Post Patron
Post Patron

Row number in calculated table

Hi, How can I add row number in the Calculated table?

RANKX gives me the same number if the totals are the same.

21 REPLIES 21
v-frfei-msft
Community Support
Community Support

Hi @gtamir ,

 

Here we go.

running total = 
CALCULATE (
    SUM ( RunningTotalByMetupalim[TOTAL] ),
    FILTER (
        RunningTotalByMetupalim,
        RunningTotalByMetupalim[Metupal Name]
            <= EARLIER ( RunningTotalByMetupalim[Metupal Name] )
    )
)
index_ = 
RANKX (
    RunningTotalByMetupalim,
    RunningTotalByMetupalim[running total],
    ,
    ASC,
    DENSE
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thanks @v-frfei-msft  but I don't understand the RunningTotal.

In my formula, I sort TOTAL first, and then Cumulative Total aggregates the totals. In your Running total it is not.

You sort the table by the name.

ScreenHunter_183.jpg 

@gtamir ,

 

What is your excepted result?

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

@v-frfei-msft A series of numbers from 1 to the end. If I refer to TOTAL, If some values are the same, I want the index to go forward and not to rank them the same.  

az38
Community Champion
Community Champion

hi @gtamir 

try

IndexColumn = CALCULATE(
COUNT('Table1'[Column1]);
FILTER(ALLSELECTED('Table1');'Table1'[Column1]<= MAX('Table1'[Column1]))
)

do not hesitate to give a kudo to useful posts and mark solutions as solution

LinkedIn


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

@az38  thanks for the quick answer. What should be Table1? It does not allow me to enter the current table.

az38
Community Champion
Community Champion

@gtamir 

Why?

after creating your calculated table to data model it appears in the right Fields Pane. the you can create a new measure in this table. So, Table1 is your calculated table, Column1 is a field that will determine index order

alternatively, you can use ADDCOLUMNS function over your statement that defines your calculated table. we will try to help you, if you share your table formula here

do not hesitate to give a kudo to useful posts and mark solutions as solution

 

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

The first suggestion is a measure so I can use it in a visual.

Here is the formula and the table.

ScreenHunter_178.jpg

az38
Community Champion
Community Champion

@gtamir 

I see Index field. couldn't it be used as row number?

try to add a measure into you table 

IndexColumn = CALCULATE(
COUNT('RunningTotalByMetupalim'[Total]);
FILTER(ALLSELECTED('RunningTotalByMetupalim');'RunningTotalByMetupalim'[Total]<= MAX('RunningTotalByMetupalim'[Total]))
)

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

The index is RANKX. It gives the same rank if the total is the same. Then the accumulative total is wrong.

What do you mean measure? I need to add a column.

az38
Community Champion
Community Champion

well @gtamir measure it's a like column but more complex 🙂

anyway you can try to use column with the same formula as above, but im not sure it will work

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

No, I tried that.

ScreenHunter_179.jpg

az38
Community Champion
Community Champion

@gtamir 

change ";" to comma ","

it depends on system localization

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Still says unexpected expression, 

ScreenHunter_181.jpg

I changed the other comma but it gives me the same number all over.

ScreenHunter_182.jpg

az38
Community Champion
Community Champion

@gtamir 

create new measure with the formula as above

882908.png

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

OK, What to do with it? 

az38
Community Champion
Community Champion

@gtamir 

share your pbix-file, please, for example at https://uploadfiles.io/

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

OK I'll cut it and send it later. Thanks

https://drive.google.com/file/d/1tmi9FjsBuooX5Gl1gkPR0GT6ZxZZhaBV/view?usp=sharing

You can see that row 10 and 11 have the same rank (10).

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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