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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Sunila
Helper I
Helper I

Identify Leave Rows with Matching Dates and One Entry Cancelled (0 Hours)

I have a following leave dataset where employees submit leave requests in hours. Sometimes a leave request (e.g., for 4 hours) is later cancelled. In the data, this cancelled entry appears as a separate row with 0 hours and a status of "Completed", while the original request has between 1 to 8 hours.

 

I would like to create a DAX calculated column that identifies this kind of pair:

  • Two rows with the same LeaveDate (and ideally the same EmployeeID),

  • One of them has Hrs = 0 and Status = "Completed",

  • The other has Hrs between 1 and 8.

The goal is to flag the 0-hour "Completed" row as a cancellation of a previous leave request.

Any guidance or sample DAX would be greatly appreciated!

 

Sunila_0-1746718452809.png

 

1 ACCEPTED SOLUTION
techies
Super User
Super User

Hi @Sunila please try this calculated column

 

IsCancellation =
VAR CurrentEmployee = Sheet5[EmployeeID]
VAR CurrentDate = Sheet5[LeaveDate]
VAR CurrentHrs = Sheet5[Hrs]
VAR CurrentStatus = sheet5[Status]

RETURN
IF (
    CurrentHrs = 0 && CurrentStatus = "Completed" &&
    CALCULATE (
        COUNTROWS (sheet5 ),
        FILTER (
            sheet5,
            sheet5[EmployeeID] = CurrentEmployee &&
            sheet5[LeaveDate] = CurrentDate &&
            sheet5[Hrs] >= 1 && Sheet5[Hrs] <= 8
        )
    ) > 0,
    "Yes",
    "No"
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

View solution in original post

3 REPLIES 3
techies
Super User
Super User

Hi @Sunila please try this calculated column

 

IsCancellation =
VAR CurrentEmployee = Sheet5[EmployeeID]
VAR CurrentDate = Sheet5[LeaveDate]
VAR CurrentHrs = Sheet5[Hrs]
VAR CurrentStatus = sheet5[Status]

RETURN
IF (
    CurrentHrs = 0 && CurrentStatus = "Completed" &&
    CALCULATE (
        COUNTROWS (sheet5 ),
        FILTER (
            sheet5,
            sheet5[EmployeeID] = CurrentEmployee &&
            sheet5[LeaveDate] = CurrentDate &&
            sheet5[Hrs] >= 1 && Sheet5[Hrs] <= 8
        )
    ) > 0,
    "Yes",
    "No"
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
maruthisp
Super User
Super User

Hi Sunila,

It would be great if you can provide some sample data. Thanks in advance.

/* =====================================================================  */

If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated — thanks! 

 

Best Regards, 

Maruthi 

LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/ 

X            -  Maruthi Siva Prasad - (@MaruthiSP) / X 
/* =====================================================================  */

saritasw
Resolver II
Resolver II

Hi @Sunila ,

To identify cancellations in your leave data, you can create a calculated column that checks for two key conditions:

The current row shows 0 hours and has a "Completed" status (indicating a cancellation).

There is another row for the same employee and same leave date with a leave request between 1 to 8 hours (indicating the original request).

If both conditions are met, the 0-hour row is flagged as a cancellation of the original leave.
This approach will help you clearly distinguish between genuine leave entries and those that represent canceled requests.


***********************************************************************************************************************

If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

Thank you,
Sarita



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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