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

IF two dates in the same month, but different dates

I'm working with HR data.  I will have a Run Date, which will typically be the first of the month.  Then, I will have another date, such as Termination Date in that file which could be any date (if that person left).  I want to mark as "1" if the Termination date is in the same month as the Run Date, else a "0"

 

For example

EmployeeStatusTermination DateFile Run Date
11111Inactive9/7/20239/1/2023

 

I want to create a custom column that would mark this as a "1" since file run date and termination date are in the same month.  If termination date had been 10/7/2023, that would be a "0".

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

=if Date.ToText([File Run Date],"yyyyMM")=Date.ToText([Termination Date],"yyyyMM") then 1 else 0

View solution in original post

3 REPLIES 3
dgkallan
Helper II
Helper II

wdx223_Daniel or anyone else for that matter,

I realized one flaw in my design.  I actually need to match up the File Run Date with the Termination Date for when the Termination was in the previous month.  So, in easy speak  (File Run Date) month - 1 month = Termination Date month 

=if Date.ToText(Date.AddMonths([File Run Date],-1),"yyyyMM")=Date.ToText([Termination Date],"yyyyMM") then 1 else 0

wdx223_Daniel
Super User
Super User

=if Date.ToText([File Run Date],"yyyyMM")=Date.ToText([Termination Date],"yyyyMM") then 1 else 0

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.