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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Harineeeeeeee
Regular Visitor

How to create index on visual table

Hey everyone
I have created a table visual with multiple colums from different table after creating the visual I would like to create a index column in the table visual how to do this ? Any leads here please?
I have tried using the below DAX that didn’t work that gave up same numbers in all rows,
Rankx(allselected(main table),calculate(max(maintable[id])),asc,dense)

So my question is how to generate incremental row values on the visual table

1 ACCEPTED SOLUTION

@Harineeeeeeee The index column is not displaying unique values because of the  ALLSELECTED function.

You can try using ALL('MainTable') instead of ALLSELECTED('MainTable')

IndexColumn = RANKX(ALL('MainTable'), 'MainTable'[id], , ASC, Dense)

Or 

Index = COUNTROWS(FILTER(ALL(MainTable), MainTable[id] < EARLIER(MainTable[id]))) + 1

 

I hope this meets your needs. If so, please consider Accepting it as the solution to help others find it more quickly. OR
If my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

 
Best Regards,
Dallas.

 

 

Best Regards,
Dallas.

View solution in original post

7 REPLIES 7
DallasBaba
Super User
Super User

@Harineeeeeeee Happy to know it works.  Kindly @ me with any future needs around Power BI and Fabric.

Please give it a kudos by clicking the Thumbs Up! It goes a long way to helping others find this solution quickly.

 
Best Regards,
Dallas.
Best Regards,
Dallas.
DallasBaba
Super User
Super User

@Harineeeeeeee your approach is right.

You can modify the query using the following formulas  

IndexColumn = RANKX(ALLSELECTED('MainTable'), 'MainTable'[id], , ASC, Dense)

 

or

Index = COUNTROWS(FILTER(ALLSELECTED(MainTable), MainTable[id] <= EARLIER(MainTable[id])))

 

Let me know if this works for you. @ me in replies, or I'll lose your thread!!!  
Note: 

If this post helps, please consider Accepting it as the solution to help others find it more quickly. OR
If my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!
 
Best Regards,
Dallas.
Best Regards,
Dallas.

@DallasBaba 

 

Thanks for the below, now the values are not unique but it gives me some random number not realy sure on what basis that random number is coming, even though i used maintabl[id] as index column which starts from 0.

 

Any thoughts on this?

 

Thanks

@Harineeeeeeee The index column is not displaying unique values because of the  ALLSELECTED function.

You can try using ALL('MainTable') instead of ALLSELECTED('MainTable')

IndexColumn = RANKX(ALL('MainTable'), 'MainTable'[id], , ASC, Dense)

Or 

Index = COUNTROWS(FILTER(ALL(MainTable), MainTable[id] < EARLIER(MainTable[id]))) + 1

 

I hope this meets your needs. If so, please consider Accepting it as the solution to help others find it more quickly. OR
If my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

 
Best Regards,
Dallas.

 

 

Best Regards,
Dallas.

@DallasBaba  Thanks and Kudos! It worked

Daniel29195
Super User
Super User

Hello @Harineeeeeeee ,

 

are you able to show the example and the output that you would want to achieve ?  that would help alot 

 

best regards,

Harineeeeeeee_0-1705608707396.png

Considering yellow table is from table A and orange is from table b , after i create a visual combining table a and table b , i want to create a index number 
Can you please suggest any ways?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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