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

View all the Fabric Data Days sessions on demand. View schedule

Reply
romina80
Frequent Visitor

Calculate previous week values

Hello ,

I have the following table in Power Bi :

Movement typeCalendar weekActualPreviousWeek
Net Growth20245250 
Net Disconnections202452750 
Net Connections202452800 
Net Growth20250130050
Net Disconnections202501200750
Net Connections202501500800
Net Growth202502100300
Net Disconnections202502900200
Net Connections2025021000500

 

I need to find the correct formula to get the last column 'Previous Week' that is the actual value of each single movement type related to the previous week.

Thanks for the help,

Romina

1 ACCEPTED SOLUTION
ajaybabuinturi
Memorable Member
Memorable Member

Hi @romina80,

 

You can use below DAX logic to create new Calculated column 

PreviousWeek = 
VAR CurrentMovement = 'Movements'[Movement type]
VAR CurrentWeek = 'Movements'[Calendar week]
VAR PreviousWeekNumber =
    CALCULATE(MAX('Movements'[Calendar week]),
        FILTER('Movements', 'Movements'[Calendar week] < CurrentWeek))
RETURN
CALCULATE(MAX('Movements'[Actual]),
        FILTER('Movements',
                'Movements'[Movement type] = CurrentMovement &&
                'Movements'[Calendar week] = PreviousWeekNumber
            ))

ajaybabuinturi_0-1762792686480.png

 

Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.

View solution in original post

4 REPLIES 4
danextian
Super User
Super User

Hi @romina80 

Try using filtered TopN:

Prev Week = 
VAR _type = 'Table'[Movement type]
VAR _week = 'Table'[Calendar week]
VAR _prevWeekRow =
    TOPN (
        1,
        FILTER (
            'Table',
            'Table'[Calendar week] < _week && 'Table'[Movement type] = _type
        ),
        [Calendar week], DESC
    )
RETURN
    MAXX ( _prevWeekRow, [Actual] )

danextian_1-1762857891299.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=LOOKUPVALUE(Data[Actual],[Calendar week],CALCULATE(MAX(Data[Calendar week]),FILTER(Data,Data[Movement type]=EARLIER(Data[Movement type])&&Data[Calendar week]<EARLIER(Data[Calendar week]))),Data[Movement type],Data[Movement type])

Hope this helps.

Ashish_Mathur_0-1762817558430.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ajaybabuinturi
Memorable Member
Memorable Member

Hi @romina80,

 

You can use below DAX logic to create new Calculated column 

PreviousWeek = 
VAR CurrentMovement = 'Movements'[Movement type]
VAR CurrentWeek = 'Movements'[Calendar week]
VAR PreviousWeekNumber =
    CALCULATE(MAX('Movements'[Calendar week]),
        FILTER('Movements', 'Movements'[Calendar week] < CurrentWeek))
RETURN
CALCULATE(MAX('Movements'[Actual]),
        FILTER('Movements',
                'Movements'[Movement type] = CurrentMovement &&
                'Movements'[Calendar week] = PreviousWeekNumber
            ))

ajaybabuinturi_0-1762792686480.png

 

Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.

MM_DATA
Helper I
Helper I

have you got a date tabel ?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors