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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
dokat
Post Prodigy
Post Prodigy

Creating index column to count rows

Hi I have a .pbix file from direct query data feeds from axure server.

I created a report using four tables that are linked in the back end.

 

The name of the tables are  Activity Status, Group, Families, Division. 

I created measures like Revenue, Units ie under Activity Status table and bring different atttributes from other 3 tables. How can i create index measure and calculate number of rows in the report?

 

Thanks

10 REPLIES 10
AbhinavJoshi
Responsive Resident
Responsive Resident

Hi @dokat. You can create an index column in Power Query M. I hope it helps! 

AbhinavJoshi_2-1690304584230.png

 

 

@AbhinavJoshi Thank you for your response. I am connected to the server via direct query to pull the data.I dont have access or visibility to query editor.  Is there a measure i can use, rankx didnt work for me because data is coming from 4 different tables, not from same table.

 

Thanks

Hi, I see the situation now. Create a new column in DAX, and enter this formula 

Index =
    COUNTROWS(
        FILTER(
            ALL('TableName'),
            'TableName'[UniqueKey] <= EARLIER('TableName'[UniqueKey])
        )
    )

@AbhinavJoshi i have four tables that are linked which table should i reference to? It gives below error message.

 

EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

The report is based on one table or combined of two or more tables? 

 

@AbhinavJoshi Its combined of 4 tables.

In that case, if you have any fact tables create and index on that, or simply add a card on the Visualization that shows the count of your ID. 

@AbhinavJoshi I am still getting the same error message

EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

"

Hi, try this if earlier doesn't work for you

Index =
    COUNTROWS(
        FILTER(
            ALL('TableName'),
            'TableName'[UniqueKey] <= MAX('TableName'[UniqueKey])
        )
    )

 

@AbhinavJoshi this only returned number of rows in Parent Customer table. One customer may show up multiple times in the report because they can carry multiple product line.

Please see below example. Walmart carries 200 different product lines because of that show up 200 times in the report. However above formula only return unique count of customers in " Parent Customer" table. I am trying to find out total number of rows (basically number of customer product combinations)

Hope this makes sense

CustomerItem
Walmart101
Walmart102
Target101
Kroger103
H-E-B103
H-E-B104

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors