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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
TomSinAA
Helper III
Helper III

Measure to get count of items in table by ID

I have this measure: 

Stops Per Route = var _id =  Stops[SYS_STATIC_ROUTE_ID]
var _t = SELECTCOLUMNS(FILTER(Stops,Stops[SYS_STATIC_ROUTE_ID]=_id) , "Site" , [SITE_NAME])
return
COUNTROWS(_t)
 
TomSinAA_0-1746654465002.png

 

 
It is displaying the warning: A single value for column '' in table '' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
 
 The Stops table has data like this:
SYS_STATIC_ROUTE_IDSITE NAME
1Site Name1
1Site Name2
1Site Name3
1Site Name4
1Site Name5
2Site Name 1
2Site Name 2
3Site Name 8
3Site Name 9
3Site Name 10
1 ACCEPTED SOLUTION
maruthisp
Super User
Super User

Hi TomSinAA,

As per my uunderstanding, You want to count how many unique rows (or combinations) exist per SYS_STATIC_ROUTE_ID, grouped by route.
StopsPerRoute =
CALCULATE(
DISTINCTCOUNT(Stops[SITE_NAME]),
ALLEXCEPT(Stops, Stops[SYS_STATIC_ROUTE_ID])
)

CALCULATE checks to group by SYS_STATIC_ROUTE_ID

DISTINCTCOUNT checks duplicates are not double-counted

ALLEXCEPT keeps only the SYS_STATIC_ROUTE_ID grouping

 

Please let me know if this help. Thanks in advance.

Best Regards,  

Maruthi 

LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/ 

X            -  Maruthi Siva Prasad - (@MaruthiSP) / X 

 

 

View solution in original post

6 REPLIES 6
v-venuppu
Community Support
Community Support

Hi @TomSinAA ,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please accept it as a solution and give it a 'Kudos' so other community members with similar problems can find a solution faster.

Thank you.

v-venuppu
Community Support
Community Support

Hi @TomSinAA ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

v-venuppu
Community Support
Community Support

Hi @TomSinAA ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

 

maruthisp
Super User
Super User

Hi TomSinAA,

As per my uunderstanding, You want to count how many unique rows (or combinations) exist per SYS_STATIC_ROUTE_ID, grouped by route.
StopsPerRoute =
CALCULATE(
DISTINCTCOUNT(Stops[SITE_NAME]),
ALLEXCEPT(Stops, Stops[SYS_STATIC_ROUTE_ID])
)

CALCULATE checks to group by SYS_STATIC_ROUTE_ID

DISTINCTCOUNT checks duplicates are not double-counted

ALLEXCEPT keeps only the SYS_STATIC_ROUTE_ID grouping

 

Please let me know if this help. Thanks in advance.

Best Regards,  

Maruthi 

LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/ 

X            -  Maruthi Siva Prasad - (@MaruthiSP) / X 

 

 

Ashish_Mathur
Super User
Super User

Hi,

Just create a matrix visual and drag this measure there

Measure = countrows(Data)


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
danextian
Super User
Super User

Hi @TomSinAA 

You're writing a measure so the variable needs to return a scalar value. Wrap the column with MAX, MIN or SELECTEDVALUE.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors