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
Kabeerkhan007
Frequent Visitor

Calculate total number of employee in visual by employee id or name.

hey,

I am trying  to calculate total number of employees in the last of row in visual what steps should i follow? Please help me to get rid of this.

Screenshot (153).png 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Kabeerkhan007 
You can add the Employee Name Column as a measure:

Employee Name Measure =
IF (
    HASONEVALUE ( TableName[EmpID0 ), SELECTEDVALUE ( TableName[Employee Name] ),
    COUNTROWS ( TableName )
)

View solution in original post

15 REPLIES 15
Anonymous
Not applicable

how many tables do you have. please check the relationships if you are connecting 2 tables. 

tamerj1
Super User
Super User

@Kabeerkhan007 

Incase you have duplicate ID's in the table you csn use the following measure instead of the column [Employee Name] and you shall get the nimber of employees at the bottom as requested 

Employee Name Measure =
IF (
    HASONEVALUE ( TableName[EmpID] ), SELECTEDVALUE ( TableName[Employee Name] ),
    DISTINCTCOUNT ( TableName[EmpID] )
)

@tamerj1 Still has the same visual. There is no duplicity for the count, I don't want that column to be seen in the table, but I only want the total count.

@Kabeerkhan007 

I totally understand your requirement right from the beginning. The measure I proposed should return the name in all row except in the total where you should  see the total count. I see no reason it shouldn't work!  Would please help me out with a screenshot?

tamerj1
Super User
Super User

Hi @Kabeerkhan007 
You can add the Employee Name Column as a measure:

Employee Name Measure =
IF (
    HASONEVALUE ( TableName[EmpID0 ), SELECTEDVALUE ( TableName[Employee Name] ),
    COUNTROWS ( TableName )
)
Anonymous
Not applicable

You have 2 options,

1. You can simply drag and drop EmpID in a card visual value field, and change summarization to Count

 

MajeedKhan_0-1655964642424.png

 

 

 

2. OR you can make a new measure :

EmpIDCount = COUNT(Test[EmpID])
 

MajeedKhan_0-1655964368459.png

 

 

@Anonymous Hey thanks for the suggestion. I already have card visual in my main page, I was trying to show in another visual with the help of emp id or name.

I tried your 2 option but its look like this total value is correct but in every column it is showing 1.Screenshot (154).png

Hi @Kabeerkhan007 

did you try my solution?

@tamerj1  Yes, i tried but it's visual are same as @Anonymous  said. It is showing 1 in all column, Which i don't want in my table.

@Kabeerkhan007 

The must be something wrong. Would you please share a screenshot of the code along with the result?

@tamerj1  I just want total number of employee in the last row of table without creating any other column. Is there any method to do with emp id or emp name? Screenshot (155).pngScreenshot (156).png

@Kabeerkhan007 

The closing bracket of HASONEVALUE is missing. Please fix it snd try it in your table. Then you can take the Employee Name column out of the table. 

Screenshot (157).png

Thankyou so much, Now it works absolute perfect..

PC2790
Community Champion
Community Champion

Hey @Kabeerkhan007 ,

 

You have two options here, either have a column with datatype as whole number that can be summed to show the total or have a separate measure like Countofemployees = Count(EmpID) and show it in a card viusal separately.

@PC2790 Hey thanks for the help 

Datatype is already in the whole number and I tried your second option it work and showed me the correct value but it is showing 1 in all rows.Screenshot (154).png

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.