Forum Discussion
uc
Helper II
10 months agoHelp 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 Date Deduction Date P...
- 10 months ago
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 )Please give kudos or mark it as solution once confirmed.
Thanks and Regards,
Praful
Praful_Potphode
Super User
10 months agoHi,
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
)
Please give kudos or mark it as solution once confirmed.
Thanks and Regards,
Praful
uc
Helper II
10 months agoHello 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 🙏
- Praful_Potphode10 months ago
Super User
Hi uc ,
Please check if this is what is expecetd.
Please give kudos once confirmed.
Thanks and Regards,
Praful