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
nok
Advocate II
Advocate II

Calculated table that counts number of rows from other tables

Hello!
I have three different tables in this structure:
A-Table

Category   Code
AAA21QW
AAA34RF
BBB343GG

 

B-Table

Category   Code
AAA21QW
BBBFR46
CCCGGD35
CCCFDFE3

 

C-Table

Category   Code
TTTASE43
SSSFDGF4
ZZZLIO89
TTTQW12
TTTDGFDR


I want to create a new table in PBI that counts the number of rows that exist in each table for each "Category". The result of this new table would be something like this:

Table        Category    Amount of rows
A-TableAAA2
A-TableBBB1
B-TableAAA1
B-TableBBB1
B-TableCCC2
C-TableTTT3
C-TableSSS1
C-TableZZZ1


I'm having trouble creating a new table like this... how can I do this?

1 ACCEPTED SOLUTION
V-yubandi-msft
Community Support
Community Support

Hi @nok ,

Thanks for reaching out to the Fabric community. I’ve tested this approach, and it works perfectly for counting rows per category per source table. I achieved this using a combination of SELECTCOLUMNS, UNION, and SUMMARIZE DAX functions.

FYI:

Vyubandimsft_2-1749541240471.png

 

For more clarity, I have attached the PBIX file. Please go through it, it will give you a clear picture.

Thanks for your responses @grazitti_sapna & @speedramps .

 

Give it a try and let me know if you need any further clarifications. If this solution meets your requirements, consider marking it as the accepted solution to help other community members facing similar challenges.

View solution in original post

3 REPLIES 3
V-yubandi-msft
Community Support
Community Support

Hi @nok ,

Thanks for reaching out to the Fabric community. I’ve tested this approach, and it works perfectly for counting rows per category per source table. I achieved this using a combination of SELECTCOLUMNS, UNION, and SUMMARIZE DAX functions.

FYI:

Vyubandimsft_2-1749541240471.png

 

For more clarity, I have attached the PBIX file. Please go through it, it will give you a clear picture.

Thanks for your responses @grazitti_sapna & @speedramps .

 

Give it a try and let me know if you need any further clarifications. If this solution meets your requirements, consider marking it as the accepted solution to help other community members facing similar challenges.

grazitti_sapna
Super User
Super User

Hi @nok 
1. Create a calculated table using DAX:

Go to Modeling tab → New Table

CategoryCounts =
UNION (
    SELECTCOLUMNS ( 'A-Table', "Table", "A-Table", "Category", 'A-Table'[Category] ),
    SELECTCOLUMNS ( 'B-Table', "Table", "B-Table", "Category", 'B-Table'[Category] ),
    SELECTCOLUMNS ( 'C-Table', "Table", "C-Table", "Category", 'C-Table'[Category] )
)
This creates a unified table with columns: Table and Category.

2. Now summarize this table to count rows:
Create another calculated table using:
CategoryRowCounts =
SUMMARIZE (
    CategoryCounts,
    CategoryCounts[Table],
    CategoryCounts[Category],
    "Amount of rows", COUNTROWS ( FILTER ( CategoryCounts,
        CategoryCounts[Table] = EARLIER(CategoryCounts[Table]) &&
        CategoryCounts[Category] = EARLIER(CategoryCounts[Category])
    ))
)


🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

speedramps
Super User
Super User

Try this

 

Add a "Table name" column to each table A-B-C

speedramps_0-1749483794527.png

speedramps_1-1749483802690.png

 

Append the tables to new table 

speedramps_4-1749483884669.png

Produce your report

speedramps_5-1749483963784.png

 

Please click thumbs up and accept the solution.    It works !  😀

Thank you

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.