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
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
MajeedKhan
Helper I
Helper I

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 )
)
MajeedKhan
Helper I
Helper I

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

 

 

@MajeedKhan 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 @MajeedKhan  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
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.