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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
davidv85
Frequent Visitor

Count Function

Hi All

im after some help, i have a table which lists out all current employees and also lists their line reports all data is within the same table, im trying to count for each resource how many line reports they have - see below what im trying to achieve (in red)

 

the first column are all unique whereas they could appear multiple times in the second column throughout the table, i have tried various count functions and cant get it to work, relatively new to power BI, any help is much appreciated

 

 

Current empLine reportNo of line reports
Resource 1Resource20
Resource2Resource23
Resource3Resource20
1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

You can try this expression in a measure, replacing Table with your actual table name.

 

No. of Line Reports =
VAR thisresource =
MIN ( Table[Current emp] )
RETURN
CALCULATE (
COUNTROWS ( Table ),
ALL ( Table ),
Table[Line Report] = thisresource
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
JonClemo
Regular Visitor

You could achieve the count by using 'group by' on the line report column. This would however effectively remove the other column - so you would be left with Resource and No. of line reports. I guess if you duplicated the table you could then join the grouped table to the original using the resource as the key - this would give you your desired layout . Someone else may have a more elegant solution. 

mahoneypat
Employee
Employee

You can try this expression in a measure, replacing Table with your actual table name.

 

No. of Line Reports =
VAR thisresource =
MIN ( Table[Current emp] )
RETURN
CALCULATE (
COUNTROWS ( Table ),
ALL ( Table ),
Table[Line Report] = thisresource
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Worked perfectly Thank you very much!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors