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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
B00m3r
Frequent Visitor

Countrows(Values confusion

As part of my finance model I have a table Purchase Orders with several columns of which one is [PO Number] as below. 

 

Purchase Orders TablePurchase Orders Table

If I go to PowerBI data area and click on PO Number I see the Table: references with distinct values as shown below.

Distinct Values as shownDistinct Values as shown

If I create a table and drag Purchase Orders into Visual level filters & select Count (Distinct) [see below] i get the result 102

Count (Distinct)Count (Distinct)

If I create the measure Count rows = COUNTROWS(VALUES('Purchase Orders'[PO NUMBER] )) i get the number 103

 

The DATA comes from an excel spreadsheet.

 

I'm trying to udnerstand what countrows is doing and whether this is the incorrect measure to use to count rows?

Regards B00M3R

3 REPLIES 3
MattAllington
Community Champion
Community Champion

 countrows is the correct formula, but you shouldn't need values. Just count the rows of the table (given po is unique).

 

This is very strange. Any chance that you have two tables that contain PO number? 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Hi Matt

Yes i have discovered it in the main data fact table. Would this be the issue?

 

Hi @B00m3r,

 

In my test, COUNTROWS function returns correct result, the same as selecting Count(distinct) for field. So, I think this problem is related to specific data. Could you provide more sample data or share .pbix file directly?

 

Besides, please try below measure to check whether it returns 102 or 103.

Count rows = DISTINCTCOUNT('Purchase Orders'[PO NUMBER] )

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Solution Authors