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
uc
Helper II
Helper II

Help with dax

Hello, I wanted to know the number of employees who are active between the financial year 2024/25 (April 2024 to MAr 2025).

 

Sample table is given below

 

Registration DateDeduction DatePerson ID
01.02.202425.02.20251
01.01.202315.06.20242
01.01.201524.06.20193
01.02.201922.02.20234
27.03.202116.09.20235
01.03.202515.03.20251
17.08.202431.12.20242
03.03.202312.12.20244
26.04.202412.12.20244
01.01.202408.08.20245
24.03.2025 1
01.01.2025 2
01.02.202423.03.20253
01.01.202506.06.20254
02.04.202530.09.20255

 

Result table must be as below where the latest registration is on or before 31/03/2025 and the deduction date can be empty (which implies they are still active) or  must be on or after 01/04/2024. Can you please help with the dax code for this requirement? Thanks in advance.

Registration DateDeducted datePerson ID
24.03.2025 1
01.01.2025 2
01.02.202425.03.20253
01.01.202506.06.20254
01.01.202408.08.20245
1 ACCEPTED SOLUTION
Praful_Potphode
Solution Sage
Solution Sage

Hi,

you can create a measure which will give output as 0 or 1 based on your data and then add it to your table visual.

IsActive_FY2425 = 
VAR FY_Start = DATE(2024, 4, 1)  // if you want you can take this from slicer using selected value
VAR FY_End   = DATE(2025, 3, 31)  // if you want you can take this from slicer using selected value

-- 1. Get the current row context from the visual
VAR CurrentPerson = SELECTEDVALUE('YourTable'[Person ID])
VAR CurrentReg    = SELECTEDVALUE('YourTable'[Registration Date])
VAR CurrentDed    = SELECTEDVALUE('YourTable'[Deduction Date])

-- 2. Find the LATEST Registration Date (Chronologically)
-- We only care that the registration happened before the FY ended.
VAR MaxValidRegDate = 
    CALCULATE(
        MAX('YourTable'[Registration Date]),
        FILTER(
            ALLEXCEPT('YourTable', 'YourTable'[Person ID]),
            'YourTable'[Registration Date] <= FY_End
        )
    )

RETURN
    IF(
        -- Check A: Is this the Latest Record?
        CurrentReg = MaxValidRegDate 
        && 
        -- Check B: Is the Deduction Date Valid?
        -- (Logic: It is BLANK (Active) OR it is AFTER the FY Start)
        (
            ISBLANK(CurrentDed) || CurrentDed >= FY_Start
        ),
        1, 
        0
    )

Praful_Potphode_0-1764217671225.png

Sample PBIX.

 

Please give kudos or mark it as solution once confirmed.

 

Thanks and Regards,

Praful

 

 

View solution in original post

7 REPLIES 7
Praful_Potphode
Solution Sage
Solution Sage

Hi,

you can create a measure which will give output as 0 or 1 based on your data and then add it to your table visual.

IsActive_FY2425 = 
VAR FY_Start = DATE(2024, 4, 1)  // if you want you can take this from slicer using selected value
VAR FY_End   = DATE(2025, 3, 31)  // if you want you can take this from slicer using selected value

-- 1. Get the current row context from the visual
VAR CurrentPerson = SELECTEDVALUE('YourTable'[Person ID])
VAR CurrentReg    = SELECTEDVALUE('YourTable'[Registration Date])
VAR CurrentDed    = SELECTEDVALUE('YourTable'[Deduction Date])

-- 2. Find the LATEST Registration Date (Chronologically)
-- We only care that the registration happened before the FY ended.
VAR MaxValidRegDate = 
    CALCULATE(
        MAX('YourTable'[Registration Date]),
        FILTER(
            ALLEXCEPT('YourTable', 'YourTable'[Person ID]),
            'YourTable'[Registration Date] <= FY_End
        )
    )

RETURN
    IF(
        -- Check A: Is this the Latest Record?
        CurrentReg = MaxValidRegDate 
        && 
        -- Check B: Is the Deduction Date Valid?
        -- (Logic: It is BLANK (Active) OR it is AFTER the FY Start)
        (
            ISBLANK(CurrentDed) || CurrentDed >= FY_Start
        ),
        1, 
        0
    )

Praful_Potphode_0-1764217671225.png

Sample PBIX.

 

Please give kudos or mark it as solution once confirmed.

 

Thanks and Regards,

Praful

 

 

Thanks 🙂

 

Hello Praful, thankyou the code works! can you please show me how to set up a slicer in your sample file so that the FY_Start and FY_End can be changed to any date. Thankyou in advance 🙏 

Hi @uc ,

Please check if this is what is expecetd.

sample PBIx Page 2

 

Please give kudos once confirmed.

 

Thanks and Regards,

Praful

Thanks a lot. Much appreciated 🙏

v-pnaroju-msft
Community Support
Community Support

Thankyou, @amitchandak for your response.

Hi uc,

We appreciate your question on the Microsoft Fabric Community Forum.

Based on my understanding of the issue, please find attached a screenshot and a sample PBIX file that may assist in resolving the matter:

vpnarojumsft_0-1764175894628.png

We hope the information provided helps to resolve the issue. Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.

Thank you.

amitchandak
Super User
Super User

@uc , With a date tbale having active join Registration date and inactive join with Deducted date 

Current Employees = CALCULATE(COUNTx(FILTER(Employee,Employee[Registration Date]<=max('Date'[Date]) && (ISBLANK(Employee[Deducted Date]) || Employee[Deducted Date]>max('Date'[Date]))),(Employee[Person Id ])),CROSSFILTER(Employee[Registration  Date],'Date'[Date],None))


Refer to the file attached after the signature 

 

 

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
Power BI HR Active Employee Tenure Bucketing, and Hired, Terminated, and Active employees: https://youtu.be/fvgcx8QLqZU

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.