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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SophRow
Resolver II
Resolver II

Add column to show 'new hires' - HR data

Hi,

 

I have a large dataset from HR which contains headcount reports that are run each month.

 

I want to create a new column called 'Hired in the Month' that contains the value 'Hired' if the hire date falls within the report month date. So the output would look like the below.

 

Any help greatly appreciated 🙂

 

Soph

 

SophRow_0-1679532763242.png

 

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @SophRow 

 

Download example PBIX file

 

You haven't said if you want the column created in Power Query or in DAX so here's both 

 

PQ

 

= if Date.Month([Report Month]) = Date.Month([Hire Date]) then "Hired" else null

 

 

DAX Column

 

Hired DAX = IF(MONTH([Report Month]) = MONTH([Hire Date]), "Hired")

 

 

If you just want to use a measure and not create a column

Hired Measure = IF(MONTH(SELECTEDVALUE('DataTable'[Report Month])) = MONTH(SELECTEDVALUE('DataTable'[Hire Date])), "Hired")

 

hires.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

SophRow
Resolver II
Resolver II

Done! 

 

= Table.AddColumn(#"Added Conditional Column", "Custom", each if Date.Month([Report Month]) = Date.Month([Hire Date]) and Date.Year([Report Month]) = Date.Year([Hire Date]) then "Hired" else null)

View solution in original post

3 REPLIES 3
SophRow
Resolver II
Resolver II

Done! 

 

= Table.AddColumn(#"Added Conditional Column", "Custom", each if Date.Month([Report Month]) = Date.Month([Hire Date]) and Date.Year([Report Month]) = Date.Year([Hire Date]) then "Hired" else null)

PhilipTreacy
Super User
Super User

Hi @SophRow 

 

Download example PBIX file

 

You haven't said if you want the column created in Power Query or in DAX so here's both 

 

PQ

 

= if Date.Month([Report Month]) = Date.Month([Hire Date]) then "Hired" else null

 

 

DAX Column

 

Hired DAX = IF(MONTH([Report Month]) = MONTH([Hire Date]), "Hired")

 

 

If you just want to use a measure and not create a column

Hired Measure = IF(MONTH(SELECTEDVALUE('DataTable'[Report Month])) = MONTH(SELECTEDVALUE('DataTable'[Hire Date])), "Hired")

 

hires.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Philip - sorry i just checked and it's doesn't work as it only takes month into account and not year  - can you possibly help again?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors