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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
croberts21
Continued Contributor
Continued Contributor

How do I count the number of rows in a table with the same job number?

Power BI version July 2024 on Windows Server 2019. We get data from a Data Lake (MS Azure Synapse Analytics SQL).

I have a table called "jobdetail". On this table are 2 fields: Jobid and jobdetailid. A jobid can have 1 or more jobdetailids listed for it. In a table viz I want to list each jobid once and list the number of jobdetailids for that jobid.

Example:

 

Jobid Count of Jobdetailid
1000  1
1001 1
1002  3
1003   4
1004 2

 

 

How do I do this? I thought I could add a column to the query with a dax formula but COUNT() counts all records in the query and returns the same number for each jobid. The number is about 20,000.

Thank you! You've been very helpful over the years.

 

EDIT: I will have to swing back to this in a week or so. Please be patient. Another project came up. 

 

3 ACCEPTED SOLUTIONS
Kedar_Pande
Super User
Super User

Create a Measure for Counting jobdetailid:

Jobdetailid_Count = COUNT(jobdetail[jobdetailid])

Drag Jobid from the jobdetail table into the table visual.
Then, drag the Jobdetailid_Count measure you created into the visual.

 

If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

View solution in original post

_AAndrade
Super User
Super User

Hi @croberts21,

I did a quick example with this data:

_AAndrade_0-1728900747485.png

My DAX measure is this:

 

Count Job ID = COUNT('Table'[Jobdetailid])

 

 And the final output was this:

_AAndrade_1-1728900810442.png

 

I hpoe this could help you.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

danextian
Super User
Super User

hI @croberts21 

 

If you simply want to count the number of jobdetailsid for each jobid and each row represents a single jobdetailsid, you can either COUNTROWS ( 'table' ) or COUNT ( 'table'[job id]) or any column from that same table.





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.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

hI @croberts21 

 

If you simply want to count the number of jobdetailsid for each jobid and each row represents a single jobdetailsid, you can either COUNTROWS ( 'table' ) or COUNT ( 'table'[job id]) or any column from that same table.





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.
_AAndrade
Super User
Super User

Hi @croberts21,

I did a quick example with this data:

_AAndrade_0-1728900747485.png

My DAX measure is this:

 

Count Job ID = COUNT('Table'[Jobdetailid])

 

 And the final output was this:

_AAndrade_1-1728900810442.png

 

I hpoe this could help you.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Kedar_Pande
Super User
Super User

Create a Measure for Counting jobdetailid:

Jobdetailid_Count = COUNT(jobdetail[jobdetailid])

Drag Jobid from the jobdetail table into the table visual.
Then, drag the Jobdetailid_Count measure you created into the visual.

 

If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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