Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
h4_dkj
Helper I
Helper I

Calculate YTD, TP, LYTD

Hi

 

I have a base table that shows me kpi values for several business measures.

It looks like this, you get the idea I hope:

IDYearMonthTypenameValue
120211FinanceCost111
220211SalesIncome222
120212FinanceCost123
320212HMSInjuries1
220212SalesIncome234
120213FinanceCost145
32021

3

HMSInjuries2
320213SalesIncome231
120201FinanceCost123
120202FinanceCost150
120203FinanceCost199
320203HMSInjuries1

 

Now what I need to solve is to create a Value_YTD, Value_TP, Value_LYTD, Value_LTP, Diff_YTD(5) for month 3

KPIValue_YTDValue_TPValue_LYTDValue_LTPDiff_YTD(%)
1 - Finance - cost379145572199 
2 - Sales - Income687231   
3 - HMS - Injuries3211 

 

How do i solve this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @h4_dkj ,

 

Please consider taking calendar tables into account for future modeling so that more and more powerful time-intelligent functions can be used. 

 

First create a new calculated column.

ID_Type_Name = 'Table'[ID] & " - " & 'Table'[Type] & " - " & 'Table'[name]

vcgaomsft_0-1656481565240.png

Then create these measures.

Value_YTD = 
CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Year] = MAX ( 'Table'[Year] ) )
Value_TP = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Year] = MAX ( 'Table'[Year] )
            && 'Table'[Month] = MAX ( 'Table'[Month] )
    )
)
Value_LYTD = 
CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Year] = MAX ( 'Table'[Year] ) - 1 )
Value_LTP = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Year] = MAX ( 'Table'[Year] ) - 1
            && 'Table'[Month] = MAX ( 'Table'[Month] )
    )
)
Diff_YTD(%) = 
VAR _rate =
    DIVIDE ( [Value_YTD] - [Value_LYTD], [Value_YTD] )
VAR _result =
    IF ( [Value_LYTD] = BLANK (), BLANK (), _rate )
RETURN
    _result

vcgaomsft_1-1656481749084.png

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @h4_dkj ,

 

Please consider taking calendar tables into account for future modeling so that more and more powerful time-intelligent functions can be used. 

 

First create a new calculated column.

ID_Type_Name = 'Table'[ID] & " - " & 'Table'[Type] & " - " & 'Table'[name]

vcgaomsft_0-1656481565240.png

Then create these measures.

Value_YTD = 
CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Year] = MAX ( 'Table'[Year] ) )
Value_TP = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Year] = MAX ( 'Table'[Year] )
            && 'Table'[Month] = MAX ( 'Table'[Month] )
    )
)
Value_LYTD = 
CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Year] = MAX ( 'Table'[Year] ) - 1 )
Value_LTP = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Year] = MAX ( 'Table'[Year] ) - 1
            && 'Table'[Month] = MAX ( 'Table'[Month] )
    )
)
Diff_YTD(%) = 
VAR _rate =
    DIVIDE ( [Value_YTD] - [Value_LYTD], [Value_YTD] )
VAR _result =
    IF ( [Value_LYTD] = BLANK (), BLANK (), _rate )
RETURN
    _result

vcgaomsft_1-1656481749084.png

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

SpartaBI
Community Champion
Community Champion

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.