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

Calculate Experience in Dax

I have Employee Table and Date Table.

I have a slicer of Year Month. Based on the selection the summary dashboard shows the Active head count as on last day of the month seleceted in year month slicer.

From the summary page i have drill through which shows the active employee details. The drill through works fine. 

The issue is I am not able to caculate the experience based on the DOJ and the last day of the month which I selected in the Year Month Slicer.

e.g: The DOJ is 1st Jan 2020 then If I choose Dec2020 then the exp should be displayed as 1 year and if I choose Jun2021 then it should show as 1.5 years.

How do I achieve using the DAX?

I tried the below DAX, but it always calculates the experience as of today not as of the selection.

 

Exp =
    VAR Total_Exp_Tmp   =
        IF(
                Employee[STATUS]=="S",
                ROUND(DATEDIFF(Employee[JOIN_DATE],Employee[EXIT DATE],MONTH)/12,2),
                ROUND(DATEDIFF(Employee[JOIN_DATE],Max(Dates[Date]),MONTH)/12,2)
        )
    Return Total_Exp_Tmp

 

3 REPLIES 3
Greg_Deckler
Super User
Super User

@sheik Try EOMONTH(Max(Dates[Date]),0)


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

It doenst help, since Max(Dates[Date]) retuns the max date in the table which is always today date. It doesnt show the last day of the selected month. FYI I am creating a new column in the Employee table using the above dax. Not creating as the measure

@sheik Well that makes no sense then. Calculated columns are calculated when the data is loaded and refreshed. Calculated columns are not interactive and don't interact with slicers so you are never going to be able to achieve what you want with a calculated column, you need to use a measure.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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