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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
BHarm65
Frequent Visitor

Calculate sum over previous years

Hi,

 

I have a question about a date calculation.

I have a report that needs to calculate the values of fixed assets.

 

The reports need to display the selected year for certain columns and for other columns the totals unit the selected year.

See example below

BHarm65_0-1702385281001.png

The columns Additions, Depreciation and Disposal display the values from  the selected year.

But the column Acquisitions prior years needs to display the value of the Aqcuisition prior to the selected year.

 

In the example I selected 2022 and need to know the Acquisition value until 2021

I created a measure but it still respond to the date slices.

I also tried a measure to disgard the date slicer but it will give me all the values, not until 2021

 

Acquisitions prio years =
CALCULATE (
    SUM ( faLedgerEntry[amount] ),
    faLedgerEntry[faPostingType] = "Acquisition Cost",
    ALL ('Calendar'[Year]))
 
I also extracted the year from the date slicer and add it to a filter in a measure, but it still gives me the selected year.
Selected Year =
CALCULATE (
    MAX( 'Calendar'[Year] )
)
 
Has anyone a suggestion for me how to calculate the value of the prior years?
Many thanks in advance
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @BHarm65 ,

 

I made simple samples and you can check the results below:

vtianyichmsft_0-1702536849985.png

vtianyichmsft_1-1702536864231.png

You just need to add conditions to the fiter according to your needs.

 

Measure = var _select= SELECTEDVALUE(DimDate[Year])
return SUMX(FILTER('Table',[Date].[Year]<_select),[Value])

 

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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
Anonymous
Not applicable

Hi @BHarm65 ,

 

I made simple samples and you can check the results below:

vtianyichmsft_0-1702536849985.png

vtianyichmsft_1-1702536864231.png

You just need to add conditions to the fiter according to your needs.

 

Measure = var _select= SELECTEDVALUE(DimDate[Year])
return SUMX(FILTER('Table',[Date].[Year]<_select),[Value])

 

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Fowmy
Super User
Super User

@BHarm65 

Use the following measrue:

Acquisitions prio years =
VAR __SelectedYear =  MAX( 'Calendar'[Year] )
RETURN
CALCULATE (
    SUM ( faLedgerEntry[amount] ),
    faLedgerEntry[faPostingType] = "Acquisition Cost",
    'Calendar'[Year] < __SelectedYear
)

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

BHarm65
Frequent Visitor

So extra information.

I tried the DAX function SAMEPERIODLASTYEAR but this only will give me the previous year and not all the years before the selected year.

I need to calculate the value from 2018 unit the selected year.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors