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
Edgar89
Frequent Visitor

Employee Anniversary

Hi all,

 

in the community are several similar questions - but no one works for me by now. I want to have the anniversarys of employees. (5 years, 10 years, 15 years, 20 years, 25 years, 30 years)

Here is an example of my data (I have a date table as well)

Edgar89_1-1651149588282.png

 

 

If I choose the filter "May 2022" I would like to have this output:

Edgar89_2-1651149613136.png

Employee "D" should not be shown (6years..)

 

If I choose "November 2022" the output should look like following:

Edgar89_3-1651149740459.png

 

Any ideas?

Thanks so far 🙂

1 ACCEPTED SOLUTION
AlexanderPrime
Solution Supplier
Solution Supplier

In Power Query. Create Custom Columns for each anniversary date using the below code

 

= Table.AddColumn(#"Changed Type", "5yr", each Date.AddYears([Employment Date],5))

 

Change the 5 for your additional landmark year

 

AlexanderPrime_2-1651217796987.png

 

When this is done, select all your anniversary date columns in Power Query. Then select "Unpivot Columns".

 

AlexanderPrime_1-1651217773942.png

 

 

You should then see it merges the 5/10/15/20/25/30 year columns into two columns called "Attribute" and "Value"

Attribute will be the anniversary type and Value will be the date so you can then rename and use those as your lookup on the table above .

But also make sure the generated "Value" column has it's data type changed to Date, you may need to do this yourself as it is likely not automatically done. 

 

AlexanderPrime_0-1651217741414.png

 

Then to make a filter for Month/Year. In DAX. Make the following column (not measure!):

 
MonthYear = FORMAT(Table1[Value],"mmm-yyyy")
 
This will give you a "month and year lookup" you can add to a relationship to a calendar table and then use as a "select month/year" filter so you can then get your intended result. 




Please note - I am not affiliated with Microsoft, I'm just an end user like yourself.
Just a regular guy doin' Data Science.

If my post has helped you, please don't forget to thumbs up or click "Accept as solution" if it solved your problem!

View solution in original post

1 REPLY 1
AlexanderPrime
Solution Supplier
Solution Supplier

In Power Query. Create Custom Columns for each anniversary date using the below code

 

= Table.AddColumn(#"Changed Type", "5yr", each Date.AddYears([Employment Date],5))

 

Change the 5 for your additional landmark year

 

AlexanderPrime_2-1651217796987.png

 

When this is done, select all your anniversary date columns in Power Query. Then select "Unpivot Columns".

 

AlexanderPrime_1-1651217773942.png

 

 

You should then see it merges the 5/10/15/20/25/30 year columns into two columns called "Attribute" and "Value"

Attribute will be the anniversary type and Value will be the date so you can then rename and use those as your lookup on the table above .

But also make sure the generated "Value" column has it's data type changed to Date, you may need to do this yourself as it is likely not automatically done. 

 

AlexanderPrime_0-1651217741414.png

 

Then to make a filter for Month/Year. In DAX. Make the following column (not measure!):

 
MonthYear = FORMAT(Table1[Value],"mmm-yyyy")
 
This will give you a "month and year lookup" you can add to a relationship to a calendar table and then use as a "select month/year" filter so you can then get your intended result. 




Please note - I am not affiliated with Microsoft, I'm just an end user like yourself.
Just a regular guy doin' Data Science.

If my post has helped you, please don't forget to thumbs up or click "Accept as solution" if it solved your problem!

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.