Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
4 years ago

Calculate Percentage Last Increase

Hello!

I have the following information in the dataset. My datasets are distinguished from month to month by the "last day of the month" column.

Employee IDLast day of the monthLast IncreaseMonthly Total
10031/1/20221/8/20211000
10028/2/20221/2/20221500
10031/3/20221/2/20221500
20031/1/20221/8/20211000
20028/2/20221/2/20221500
20031/3/20221/3/20221700

I need to be able to calculate the % of the last increment of each employee ID and then put it in a table, is there a way to do it? The result I need to get would be as follows:

Employee IDLast day of the monthLast IncreaseMonthly TotalLast % increase
10031/1/20221/8/202110000%
10028/2/20221/2/2022150050%
10031/3/20221/2/2022150050%
20031/1/20221/8/202110000%
20028/2/20221/2/2022150050%
20031/3/20221/3/2022170013%

Thank you!!

1 Reply

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Syndicate_Admin 
    Here is a sample file with the solution https://www.dropbox.com/t/VxePA5I71I36fxiz

    Last % increase = 
    VAR CurrentDate = Payroll[Last day of the month]
    VAR CurrentSalary = Payroll[Monthly Total]
    VAR CurrentEmployeeTable = CALCULATETABLE ( Payroll, ALLEXCEPT ( Payroll, Payroll[Employee ID] ) )
    VAR DatesBeforeTable = FILTER ( CurrentEmployeeTable, Payroll[Last day of the month] < CurrentDate )
    VAR PreviousDate = MAXX ( DatesBeforeTable, Payroll[Last day of the month] )
    VAR PreviousSalay = MAXX ( FILTER ( DatesBeforeTable, Payroll[Last day of the month] = PreviousDate ), Payroll[Monthly Total] )
    RETURN
        DIVIDE ( CurrentSalary - PreviousSalay, PreviousSalay, 0 )