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
robhel
Helper I
Helper I

Year Month Calculation on TODAY ()

Hello Guru's

 

Looking for your expert advice on how to achieve the following scenario of calculating the number of Year’s & Months from TODAY() until next lot of Long Service Leave (LSL) will be available.

 

There are 2 parts to this scenario:

 

LSL is available after 10years from commencement date

Additional 9days LSL for every year after 10yrs based on commencement date

 

I’ve came up with an extremely hack work-around for both steps above, which is still not providing me with required results:

 

Step 1)

From my table “CurrentEmployee”, I’ve split [Commencement Date] to DDMM and then included 2019 to it

 

I created a second table for employee’s that are under 10years, adding [Year] + 10 to commencement date

 

Then merged the 2 fields together providing existing LSL & upcoming LSL

 

 

Step 2)

 

I applied a new column with the following:

 

DaysLSL =

 

VAR Months = DATEDIFF(TODAY(),[MergedField],MONTH)

VAR Years = ROUNDDOWN(Months/12,0)

RETURN CONCATENATE(CONCATENATE(Years, “.”),Months-(Years*12)))

 

Which gives me the desired result, unless the date is prior to TODAY (re YMResult)

 

Greatly appreciate any assistance on a way to get desired result

 

EmpIDEmpNameCommDateMergedFieldYMResultYMDesiredResult
123Rod15/10/200715/10/20190.60.6
124Jim2/08/19992/08/20190.40.4
125Barney5/02/20145/02/20244.104.10
126Carl18/02/201918/02/20299.109.10
127Hannah1/03/20081/03/20190.-1.11
128Mary9/12/19999/12/20190.80.8
129Wayne27/06/198327/06/20190.20.2
130Kelly8/01/19858/01/20190.-3.9
131Kirsty1/02/19831/02/20190.-2.10
132Emma4/03/20134/03/20233.113.11
133Lou18/10/199918/10/20190.60.6
134Sarah16/01/200616/01/20190.-3.9
135Mike22/09/200822/09/20190.50.5
136Fred15/04/199915/04/20190.00.0
1 ACCEPTED SOLUTION

@robhel ,

 

Try to change it as follows.

    CONCATENATE (
        CONCATENATE ( Years, "." ),
        MOD ( Months - ( Years * 12 ) + 12, 12 )
    )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Please explain how the answer is 0.6, 0.4, 4.10, 9.10 etc?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for response & in answer to your question, the result is based on TODAY less Commncement MMYY = number of months or years until next allocation of LSL, example

 

TODAY 27/04/2019 - 12/01/2022 Commencement Date (= 12/01/2012 + 10y) = 2years & 9Mths until LSL

TODAY 27/04/2019 - 29/10/2019 Commencement DDMM & Current Year (29/10/1979 to 29/10/2019) = .6 mths until next LSL days

 

Hope this answer your question

@robhel ,

 

Try to change it as follows.

    CONCATENATE (
        CONCATENATE ( Years, "." ),
        MOD ( Months - ( Years * 12 ) + 12, 12 )
    )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.