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
dirkkoch
Helper III
Helper III

Write values in column from last year

Hi,

I am struggling with the following. I want to create a new column, in which I want to show the value (column 3 "Anzahl Lieferungen") from last year's date (column 1 "Datum Auswertung" - 1 year) considering the value in column B ("Route", eg. Seefracht, Kurier, Luftfracht). Which formula must I use in DAX to do that?

 

dirkkoch_0-1637855990096.png

 

1 ACCEPTED SOLUTION

Hi @dirkkoch 

 

Use EDATE([date column], -12) function to get the same date in last year. This would not have that problem. For leap years, it will get last year's Feb 28th's value for this leap year's Feb 29th. 

calculatedColumn =
MAXX (
    FILTER (
        t1,
        t1[Route] = EARLIER ( t1[Route] )
            && t1[Datum Auswertung] = EDATE ( EARLIER ( t1[Datum Auswertung] ), -12 )
    ),
    t1[Anzahl Lieferungen]
)

21112901.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

 

View solution in original post

4 REPLIES 4
smpa01
Super User
Super User

@dirkkoch  can you please provide some sample data and desired output for those candidates?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
smpa01
Super User
Super User

@dirkkoch 

calculatedColumn=MAXX(filter(t1,t1[Route]=earlier(t1[Route])&&t1[Datum Auswertung]=earlier(t1[Datum Auswertung])-365),t1[Anzahl Lieferungen])
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@smpa01  thank you for the support. This works fine. Since there are also leap years with 366 days a year. How can I take care of this without having to manually adjust?

Hi @dirkkoch 

 

Use EDATE([date column], -12) function to get the same date in last year. This would not have that problem. For leap years, it will get last year's Feb 28th's value for this leap year's Feb 29th. 

calculatedColumn =
MAXX (
    FILTER (
        t1,
        t1[Route] = EARLIER ( t1[Route] )
            && t1[Datum Auswertung] = EDATE ( EARLIER ( t1[Datum Auswertung] ), -12 )
    ),
    t1[Anzahl Lieferungen]
)

21112901.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

 

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