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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Add row number to Filtered table

Hello,

I need to add to my table view a row_number column which needs to reset based on the selection. For example, if I select the territory Canada, I need to have row_numbe from 1 to 100 let's say, if I change the selection to US  I need to have 1 to 50.

 

I have tried the solution from the community with adding an index and creating a measure: 

Row_Number =
CALCULATE (
COUNTROWS(table),
FILTER ( ALLSELECTED (table ), table[Index] <= MAX ( table[Index]) )
) but the result is not the desired one ( I get 4, 8, 11, 14...). I have also filters applied in the Filter Pane from the right..

 

omihai_0-1598452120773.png

Thank you.

5 REPLIES 5
Greg_Deckler
Super User
Super User

@Anonymous - Sample data would help, but maybe the Mythical DAX Index? https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Mythical-DAX-Index/m-p/1093214#M528

 

Or maybe something dealing with RANKX? https://community.powerbi.com/t5/Quick-Measures-Gallery/To-Bleep-with-RANKX/m-p/1042520#M452

 

Or maybe Cthulhu? https://community.powerbi.com/t5/Quick-Measures-Gallery/Cthulhu/m-p/509739#M211

 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hello @Greg_Deckler , I am trying to achieve what is described here, I am using the exact same functions but my row number column has the value 1 for all rows.

 

@Anonymous - I don't have an example of what your data looks like, but I mocked something up. See what you think. PBIX is attached below sig, Table 12, Measure 12, Page 12.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hello @Greg_Deckler , thank you for your example.  I have checked my data set and it includes a Date column, which is the lowest level of detail for the data. In my report I do not display this column because I make LTD calculations. If I add this column in the data table the row number is calculated correctly: 

 

omihai_0-1598521469548.png

but if I remove that column then the numbers will be displayed incorrectly.

omihai_1-1598521583731.png

 

 

Is there any way of calculating the correct index only for the data displayed? Thank you.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.