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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
selected_
Helper IV
Helper IV

create index with measure

I'm trying to create a calculated column like 

Index = RANKX(ALL(table),table[random_column],,ASC)
 
but it does not give me unique index like 1,2,3,4, like the one you can do in power query instead I get 1,1,1,2,2,4,4,3,
 
In same time I also wonder if you save performance to work in the power query than do calculated measures and columns?
1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @selected_ ,

 

For the rankx function, the basis for processing the same ranking, skip stands for sparse ranking, and the next ranking is equal to the number of all previous rankings + 1; dense stands for dense ranking, which only accumulates the ranking, regardless of the number. 


Therefore, only the following two results can be obtained for the rank function. If you want to get a continuous and uninterrupted ranking. You can create a column index after sorting to get the desired result.

 

C1 = RANKX('Table (2)',[Value],,ASC,Dense)
C2 = RANKX('Table (2)',[Value],,ASC,Skip)

 

vhenrykmstf_0-1624263025059.png

vhenrykmstf_0-1624263632596.pngvhenrykmstf_1-1624263299145.png

 

You can use the Performance Analyzer to view the operating status of the created calculated column and measure to optimize. 

related document link: Use Performance Analyzer to examine report element performance in Power BI Desktop - Power BI | Micr...


Best Regards,
Henry

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

Hi @selected_ ,

 

For the rankx function, the basis for processing the same ranking, skip stands for sparse ranking, and the next ranking is equal to the number of all previous rankings + 1; dense stands for dense ranking, which only accumulates the ranking, regardless of the number. 


Therefore, only the following two results can be obtained for the rank function. If you want to get a continuous and uninterrupted ranking. You can create a column index after sorting to get the desired result.

 

C1 = RANKX('Table (2)',[Value],,ASC,Dense)
C2 = RANKX('Table (2)',[Value],,ASC,Skip)

 

vhenrykmstf_0-1624263025059.png

vhenrykmstf_0-1624263632596.pngvhenrykmstf_1-1624263299145.png

 

You can use the Performance Analyzer to view the operating status of the created calculated column and measure to optimize. 

related document link: Use Performance Analyzer to examine report element performance in Power BI Desktop - Power BI | Micr...


Best Regards,
Henry

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

SanketBhagwat
Solution Sage
Solution Sage

Hi @selected_ .

You can use the following DAX to create a calculated Index Column,

 

Index=
RANKX(
FILTER(table,
EARLIER(table[random_column])>table[random_column]),
table[value column],,ASC)

 

Regards,

Sanket Bhagwat.

 

If this posts helps , then please mark it as 'Accept As Solution' and give it a big thumbs up.

Same issue, I get same value back as 1,1,1,1,1,2,2,2,3,3,4 

 

I need unique index column for all rows.

There is a workaround but it would be helpful only if you are sourcing your data from 'Import' mode.

If so, then I would suggest you to first add a custom Index Column using Query Editor and then use a DAX function like,

Index1=RANKX(

                         Filter(

                                 table,

                                 EARLIER(table[random_column)>table(random_column),
                                 [Index],,ASC).

 

Although most of the users would not like this way of doing it as then we would have 2 Index columns(redudant column) and also it is not a suitable approach, but it definitely serves the purpose.

Try and let me know.

 

Regards,

Sanket Bhagwat.

 

If this posts helps, then do mark it as 'Accept as Solution' and give it a big thumbs up so that others users could find it quickly.

 

Can you please share your sample data?

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.