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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
uc
Helper II
Helper II

Help in Dax .

Hello , 

I have got a table which lists registration and deduction date for every Person ID.  I wanted to find out the active cohort as of 31.03.2025 (which means the deducted date should be blank or after 31.03.2025 and must registered on or before 31.03.2025). I am looking for the cohort where there is no deduction between the last registration and 01/04/2025.

Registration DateDeducted 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.20243
26.04.202412.12.20244
01.01.202408.08.20245
24.03.2025 1
01.01.2025 2
01.02.202425.03.20253
01.01.202506.06.20254
02.04.202530.09.20255
   

 In the above table person id 1,2 and 4 are active as of 31.03.2025. Can you help me to write dax for the above query please? Thanks

1 ACCEPTED SOLUTION
Zanqueta
Continued Contributor
Continued Contributor

Hi @uc 


I tested here, let me know if it worked for you:

Zanqueta_1-1763384622015.png

 

IsActive_31Mar2025 =
VAR ReferenceDate = DATE(2025, 3, 31)
VAR LastRegistration = 
    CALCULATE(
        MAX(fact_registration[Registration Date]),
        ALLEXCEPT(fact_registration, fact_registration[Person ID])
    )
VAR AssociatedDeduction = 
    CALCULATE(
        MAX(fact_registration[Deducted Date]),
        fact_registration[Registration Date] = LastRegistration,
        ALLEXCEPT(fact_registration, fact_registration[Person ID])
    )
RETURN
    IF(
        LastRegistration <= ReferenceDate &&
        (ISBLANK(AssociatedDeduction) || AssociatedDeduction > ReferenceDate),
        1,
        0
    )

 

 


If this response resolved your issue, please mark it as correct to assist other members of the community.

 

 



View solution in original post

5 REPLIES 5
Zanqueta
Continued Contributor
Continued Contributor

Hi @uc 


I tested here, let me know if it worked for you:

Zanqueta_1-1763384622015.png

 

IsActive_31Mar2025 =
VAR ReferenceDate = DATE(2025, 3, 31)
VAR LastRegistration = 
    CALCULATE(
        MAX(fact_registration[Registration Date]),
        ALLEXCEPT(fact_registration, fact_registration[Person ID])
    )
VAR AssociatedDeduction = 
    CALCULATE(
        MAX(fact_registration[Deducted Date]),
        fact_registration[Registration Date] = LastRegistration,
        ALLEXCEPT(fact_registration, fact_registration[Person ID])
    )
RETURN
    IF(
        LastRegistration <= ReferenceDate &&
        (ISBLANK(AssociatedDeduction) || AssociatedDeduction > ReferenceDate),
        1,
        0
    )

 

 


If this response resolved your issue, please mark it as correct to assist other members of the community.

 

 



Hello Zanqueta

Your code works thankyou. However in future if we want to change the reference date from 31.03.2025  to some other date say 31.03.2024, is there a way we can pass the value from the front end (report view) instead of going to the table view and change the date there? Thankyou in advance.

uc_0-1763391212806.png

 

Zanqueta
Continued Contributor
Continued Contributor

Hi @uc,

 

Yes, off course. The better way for me is creating a parameter

To allow users to dynamically select a reference date from the report interface, rather than hardcoding it within a DAX measure. This can be achieved by creating a parameter in Power BI Desktop that is exposed via a slicer.

 

Steps to Create a Date Parameter in Power BI

1. Create the Parameter

In Power BI Desktop:
  1. Navigate to Modelling > New Parameter > Fields.
  2. Configure the parameter as follows:
    • Name: ReferenceDate
    • Data Type: Date
    • Selection Mode: List of values or Range
    • Values: Enter the dates you wish to make available (e.g., 31/03/2024, 31/03/2025)
    • Default Value: Select an initial default date

 

Use Parameters to Visualize Variables - Power BI | Microsoft Learn

 

 

 

I tried and it works. Thankyou

amitchandak
Super User
Super User

@uc , seem very similar to HR data, refer if the attached two PBIX can help 

Current Employees = CALCULATE(COUNTx(FILTER(Employee,Employee[Start Date]<=max('Table'[Date]) && (ISBLANK(Employee[End Date])
|| Employee[End Date]>max('Table'[Date]))),(Employee[Employee Id ])))

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors