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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

Count of ID With duplicate status

Hello Everyone,
i have large attendance Database. I want to calculate how many present/absent every day.
but few IDs are having duplicate values as shown below. so the same id count is showing in present and absent also.
i have total X number of head count. for X headcount present must be some Y and Absent must be X-Y. But my Absent plus Present count is more than Headcount due to the duplicate Records. So please Help.

tejutulasi67_0-1668771610874.png

 



1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1669022240128.png

 

Please try:

Status = 
var _a = SUMMARIZE('Table',[Employee ID],[In Time],[Out Time],"Hours Worked",DATEDIFF([In Time],[Out Time],HOUR))
return IF(SUMX(_a,[Hours Worked])<>0,"Present","Absent")

Count of Absent = 
var _a = SUMMARIZE('Table',[Employee ID],[In Time],[Out Time],"Hours Worked",DATEDIFF([In Time],[Out Time],HOUR))
var _b = SUMMARIZE(_a,'Table'[Employee ID],"Hours worked",SUMX(FILTER(_a,[Employee ID]=EARLIER('Table'[Employee ID])),[Hours Worked]))
return COUNTX(FILTER(_b,[Hours worked]=0),[Employee ID])

Count of Present = 
var _a = SUMMARIZE('Table',[Employee ID],[In Time],[Out Time],"Hours Worked",DATEDIFF([In Time],[Out Time],HOUR))
var _b = SUMMARIZE(_a,'Table'[Employee ID],"Hours worked",SUMX(FILTER(_a,[Employee ID]=EARLIER('Table'[Employee ID])),[Hours Worked]))
return COUNTX(FILTER(_b,[Hours worked]<>0),[Employee ID])

Final output:

vjianbolimsft_1-1669022307990.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1669022240128.png

 

Please try:

Status = 
var _a = SUMMARIZE('Table',[Employee ID],[In Time],[Out Time],"Hours Worked",DATEDIFF([In Time],[Out Time],HOUR))
return IF(SUMX(_a,[Hours Worked])<>0,"Present","Absent")

Count of Absent = 
var _a = SUMMARIZE('Table',[Employee ID],[In Time],[Out Time],"Hours Worked",DATEDIFF([In Time],[Out Time],HOUR))
var _b = SUMMARIZE(_a,'Table'[Employee ID],"Hours worked",SUMX(FILTER(_a,[Employee ID]=EARLIER('Table'[Employee ID])),[Hours Worked]))
return COUNTX(FILTER(_b,[Hours worked]=0),[Employee ID])

Count of Present = 
var _a = SUMMARIZE('Table',[Employee ID],[In Time],[Out Time],"Hours Worked",DATEDIFF([In Time],[Out Time],HOUR))
var _b = SUMMARIZE(_a,'Table'[Employee ID],"Hours worked",SUMX(FILTER(_a,[Employee ID]=EARLIER('Table'[Employee ID])),[Hours Worked]))
return COUNTX(FILTER(_b,[Hours worked]<>0),[Employee ID])

Final output:

vjianbolimsft_1-1669022307990.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , what should it be counted when both are there? present and absent ?

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I have punch in time out time and no of hours worked fields also as shown below. if the person has working hours then present should come otherwise absent.

tejutulasi67_0-1669009612702.png

thank you.

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Users online (3,933)