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

Cumulative Year to Date with multiple categories

Hi,

 

I have a table with data for multiple employees who recieve bonuses on a monthly basis. I want to calculate the Cumulative Year to Date for each employee and display this in a table column. How do I get the cumulative YTD for each specific employee in the YTD column. I also need to get a summary for Each employee with the YTD for the given year as seen in the second table.

 

Employee BonusDateBonusYTD
Jane11/1/2016100100
Sam11/1/2016120120
Kevin11/1/2016130130
Jane12/1/2016105205
Sam12/1/2016125245
Kevin12/1/2016135165
Jane1/1/2017100100
Sam1/1/2017120120
Kevin1/1/2017130130
Jane2/1/2017105205
Sam2/1/2017125245
Kevin2/1/2017135265
Jane3/1/2017100305
Sam3/1/2017120365
Kevin3/1/2017130395

 

YearEmployeeBonus YTD
2016Jane205
2016Sam245
2016Kevin165
2017Jane305
2017Sam365
2017Kevin395
1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @qquestel,

 

Based on my test, you should be able to use the formula below to the cumulative YTD for each specific employee in the YTD column.

YTD = 
CALCULATE (
    SUM ( Table1[Bonus] ),
    FILTER (
        ALL ( Table1 ),
        Table1[Employee] = EARLIER ( Table1[Employee] )
            && Table1[BonusDate] <= EARLIER ( Table1[BonusDate] )
            && YEAR ( Table1[BonusDate] ) = YEAR ( EARLIER ( Table1[BonusDate] ) )
    )
)

c1.PNG

 

To get a summary for Each employee with the YTD for the given year, you can firstly add Year column in your table with the formula below.

Year = YEAR(Table1[BonusDate])

Then you should be able to use the formula below to create a new calculate table to get the expected result.

Table = 
SUMMARIZE (
    Table1,
    Table1[Year],
    Table1[Employee],
    "Bonus YTD", MAX ( Table1[YTD] )
)

t1.PNG

 

Here is sample pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

1 REPLY 1
v-ljerr-msft
Employee
Employee

Hi @qquestel,

 

Based on my test, you should be able to use the formula below to the cumulative YTD for each specific employee in the YTD column.

YTD = 
CALCULATE (
    SUM ( Table1[Bonus] ),
    FILTER (
        ALL ( Table1 ),
        Table1[Employee] = EARLIER ( Table1[Employee] )
            && Table1[BonusDate] <= EARLIER ( Table1[BonusDate] )
            && YEAR ( Table1[BonusDate] ) = YEAR ( EARLIER ( Table1[BonusDate] ) )
    )
)

c1.PNG

 

To get a summary for Each employee with the YTD for the given year, you can firstly add Year column in your table with the formula below.

Year = YEAR(Table1[BonusDate])

Then you should be able to use the formula below to create a new calculate table to get the expected result.

Table = 
SUMMARIZE (
    Table1,
    Table1[Year],
    Table1[Employee],
    "Bonus YTD", MAX ( Table1[YTD] )
)

t1.PNG

 

Here is sample pbix file for your reference. Smiley Happy

 

Regards

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.