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
rajasekar_o
Helper V
Helper V

Login DATE Based leave calculation

hi,team
Login date based leave calculation  heare all day are working day
Employee

EMPIDNAMEDEPT
EMPS001KUMARaccounts
EMPS002RAMIT
EMPJ003VANITESTING
EMP030THAMOaccounts
EMP032VINOTHIT

 

login 

EMPIDLOGIN DATETIMESHIFT
EMPS00101-04-20246:00 AM1
EMPS00201-04-20246:00 AM1
EMPJ00301-04-20246:00 AM1
EMP03001-04-20246:00 AM1
EMPS00102-04-20246:00 AM1
EMPS00202-04-20246:00 AM1
EMP03002-04-20246:00 AM1



expected output
if i filter the date 1/4/2024
Department wise leave

rajasekar_o_0-1725443394255.png 

if i filter the date 2/4/2024
Department wise leave
rajasekar_o_1-1725443408137.png

employee wise leave details with
if i filter the date 1/4/2024

rajasekar_o_2-1725444112783.png

if i filter the date 2/4/2024

rajasekar_o_3-1725444154569.png

 



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from bhanu_gautam , please allow me to provide another insight:

Hi, @rajasekar_o 

Regarding the issue you raised, my solution is as follows:

 

1. Below are the measure I've created for your needs:

Leave count = 
VAR ID1 =
    CALCULATETABLE ( VALUES ( 'login'[EMPID] ), ALLSELECTED ( 'login' ) )
VAR cc1 =
    CALCULATE (
        COUNT ( Employee[DEPT] ),
        FILTER ( 'Employee', NOT ( 'Employee'[EMPID] IN ID1 ) )
    )
RETURN
    IF (
        ISFILTERED ( 'login'[LOGIN DATE] ),
        IF ( ISBLANK ( cc1 ), 0, cc1 ),
        0
    )
Login = 
VAR ID2 =
    CALCULATETABLE ( VALUES ( 'login'[EMPID] ), ALLSELECTED ( 'login' ) )
RETURN
    IF (
        ISFILTERED ( 'login'[LOGIN DATE] ),
        IF ( NOT ( MAX ( 'Employee'[EMPID] ) IN ID2 ), "Leave", BLANK () ),
        BLANK ()
    )

2.Here's my final result, which I hope meets your requirements.

vlinyulumsft_0-1725523332614.png

 

vlinyulumsft_1-1725523332615.png

vlinyulumsft_2-1725523342551.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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
bhanu_gautam
Super User
Super User

@rajasekar_o , 

Ensure that the LOGIN DATE column is in date format.
Create a relationship between the EMPID in the Employee table and the EMPID in the Login table.

Create a measure to count the number of logins per day.

Total Logins = COUNT(Login[EMPID])


Create a measure to count the number of employees per department.

Employees Present = DISTINCTCOUNT(Login[EMPID])
 
Employees Absent =
VAR TotalEmployees = COUNTROWS(Employee)
VAR PresentEmployees = [Employees Present]
RETURN TotalEmployees - PresentEmployees



Create a calculated column to determine if an employee was present on a specific date.

 

Is Present =
IF(
    COUNTROWS(
        FILTER(
            Login,
            Login[EMPID] = Employee[EMPID] &&
            Login[LOGIN DATE] = SELECTEDVALUE(Login[LOGIN DATE])
        )
    ) > 0,
    "Yes",
    "No"
)



Use a slicer to filter the data by LOGIN DATE.
Create visuals to show department-wise and employee-wise leave details




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

Proud to be a Super User!




LinkedIn






@bhanu_gautam 
I try not working.
can you please share the application

Anonymous
Not applicable

Thanks for the reply from bhanu_gautam , please allow me to provide another insight:

Hi, @rajasekar_o 

Regarding the issue you raised, my solution is as follows:

 

1. Below are the measure I've created for your needs:

Leave count = 
VAR ID1 =
    CALCULATETABLE ( VALUES ( 'login'[EMPID] ), ALLSELECTED ( 'login' ) )
VAR cc1 =
    CALCULATE (
        COUNT ( Employee[DEPT] ),
        FILTER ( 'Employee', NOT ( 'Employee'[EMPID] IN ID1 ) )
    )
RETURN
    IF (
        ISFILTERED ( 'login'[LOGIN DATE] ),
        IF ( ISBLANK ( cc1 ), 0, cc1 ),
        0
    )
Login = 
VAR ID2 =
    CALCULATETABLE ( VALUES ( 'login'[EMPID] ), ALLSELECTED ( 'login' ) )
RETURN
    IF (
        ISFILTERED ( 'login'[LOGIN DATE] ),
        IF ( NOT ( MAX ( 'Employee'[EMPID] ) IN ID2 ), "Leave", BLANK () ),
        BLANK ()
    )

2.Here's my final result, which I hope meets your requirements.

vlinyulumsft_0-1725523332614.png

 

vlinyulumsft_1-1725523332615.png

vlinyulumsft_2-1725523342551.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

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.