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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

How Can I solve this Problem with the new addes Column Year Previous Year

Hello i try to understand why this is not working as I intent.
I am new and try to learn power bi pls be patient with me and if u are kind explain how and why and maybe how I could fix this.
For this example I copied a part of the Data into Excel to do screenshots here.

Ich have this Table, have to blur it cause sensitive Data:

Cango_0-1699625882254.png

I used this Formular to get this:

Table.AddColumn(
#".......",
"Profit Previous Year",
each let
CurrentDate = [Date],
FilteredTable = Table.SelectRows(#".....", each [Date] = Date.AddYears(CurrentDate, -1))
in
if Table.IsEmpty(FilteredTable) then null else FilteredTable{0}[#"Profit"])

 

What it should do is:
- getting a new Column "Profit Previous Year" and taking the information from Column "Profit" but -1 Year and it is working in the first Screenshot.
But......

Cango_1-1699626056677.png

In the second Screenshot u see that it starts all over again like in the first screenshot the 6954143 is the same Profit number as the first one. And this is data like 10k rows it just repeading to start all over again.
What in D66 should be is the Data in C54.


What can I do to solve this?


Kind Regards


6 REPLIES 6
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

Column:

Previous Profit =
CALCULATE ( SUM ( 'Table'[Profit] ),
    FILTER ( 'Table',
        YEAR ( [Date] ) = EARLIER ( 'Table'[Date].[Year] ) - 1
            && MONTH ( [Date] ) = EARLIER ( 'Table'[Date].[MonthNo] )
    )
)

vzhangti_0-1699868828018.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Anonymous
Not applicable

Could you give me an example with the column Shop 1 included? Cause I do have more than 30 Shops names and I think I need to implement these because I got the same number all over again

I am not sure what I am doing wrong

Cango_0-1699870776428.png

 

Hi, @Anonymous 

 

Column:

Previous Profit = 
CALCULATE ( SUM ( 'Table'[Profit] ),
    FILTER ( ALLEXCEPT('Table','Table'[Shop]),
        YEAR ( [Date] ) = EARLIER ( 'Table'[Date].[Year] ) - 1
            && MONTH ( [Date] ) = EARLIER ( 'Table'[Date].[MonthNo] )
    )
)

vzhangti_0-1699951517836.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

Anonymous
Not applicable

Hi, @v-zhangti
Thank you so far. It seems looking better now, but 1 think I am missing something or I dont see why.

Cango_4-1699957531301.png

 


 

The list seems doing what I want. But why is the Value not the same? Does it have to do with SUM ? The Value on the right is not in mein Source Excel and I don´t know where this came from.
If I Use ur Code on my example Table I got it all right. Its how I want it. But not on my Main Table.

Another Question!
Can I build this Code of yours in Power Query Editor ? 

Cango_5-1699957872550.png

How Do I have to change this:

Previous Profit = 
CALCULATE ( SUM ( 'Table'[Profit] ),
    FILTER ( ALLEXCEPT('Table','Table'[Shop]),
        YEAR ( [Date] ) = EARLIER ( 'Table'[Date].[Year] ) - 1
            && MONTH ( [Date] ) = EARLIER ( 'Table'[Date].[MonthNo] )
    )
)

to implement it here 

Cango_5-1699957872550.png

 

Thank you Sir/Ma´am

 

Anonymous
Not applicable

I think I can´t use measures for slicers right?
Thats why I don´t need a measure I need to do it as an column.
Or is it possible then how?

Uzi2019
Super User
Super User

Hi @Anonymous 
You can try craeting measure for Numeric field. If you want to calaculate last year sales then please write below dax;
Prev Sales= CALCULATE(SUM('Table'[Sales]),DATEADD('Calendar'(Date),-1,Year))

OR

Prev Sales=CALCULATE(SUM(Table[Sales]),SAMEPERIODLASTYEAR('Calendar'[Date]))

You will get the same result from both the measures.

Uzi2019_0-1699632397468.png

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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