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
KeithKing
New Member

How to get date difference between last logon and last password reset dates in Active Directory

Hi Guys, I would like to get the date difference between Last Logon and Last Password Reset columns and the display a warning or text that the user hasn't reset their password in x amount of days.

 

This is what I am using now but does not display the correct information:

 

     Measure =
VAR Created =
MAX ( user[user.lastLogon].[Year])
VAR Closed =
MAX ( user[user.pwdLastSet].[Year] )
VAR NoOfDays =
IF (
Closed > Created,
DATEDIFF ( Created, Closed, YEAR),
DATEDIFF ( Closed, Created, YEAR)
)
RETURN
IF ( NoOfDays >= 1, "User account Fine", "Password Needs to be Reset )

5 REPLIES 5
az38
Community Champion
Community Champion

Hi @KeithKing 

try the same but without .[Year] in Created and Closed variables

That should be enough

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi,

 

It sort of works now 🙂  but the problem is that I have an account CustomerCare1  with last logon at 2019/12/06 and last password reset at 2019/08/02.  This is a 4 month difference but it says the user account is fine? It needs to check the year as well as months (3 months after that password needs to be reset)

 

Hope I am making sense?

 

Thanks

az38
Community Champion
Community Champion

@KeithKing 

DATEDIFF ( Created, Closed, MONTH) will give you difference in monthes without any dependencies of Year

 

For example 

 

DATEDIFF ( DATE(2019,11,1), DATE(2020,1,11), MONTH) will return you 2 month difference

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thanks!! 

az38
Community Champion
Community Champion

@KeithKing 

does it work ok? 

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.