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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to get previous value

I have a sample table as below:

Display_NameEffective_DateDepartment
Jason2/1/2012TCX
Jason7/1/2012TCX
Jason7/1/2012BFDA
Jason8/14/2012BFDA
Jason8/21/2012MBCL
Jason1/19/2013MBCL


I want to show all rows in a Table visual, and add a new column that show the previous row's value of Department, and this calculation should ORDER BY Effective_Date ASC, Department ASC. And please notice that some records may have same Effective_Date value, for example: 7/1/2012.

Due to real data source has huge size, so please use measure to realize it. Thanks.

The final result should like below:

Display_NameEffective_DateDepartmentPrevious Department
Jason2/1/2012TCX 
Jason7/1/2012TCXTCX
Jason7/1/2012BFDATCX
Jason8/14/2012BFDABFDA
Jason8/21/2012MBCLBFDA
Jason1/19/2013MBCLMBCL
1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Anonymous 

 

Please try this measure:

Previous Department = 
CALCULATE (
    MAX ( 'Table'[Department] ),
    OFFSET (
        -1,
        ALLEXCEPT ( 'Table', 'Table'[Display_Name] ),
        ORDERBY ( 'Table'[Effective_Date], ASC )
    )
)

 

danextian_0-1721201106776.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.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

Hi @Anonymous 

 

Please try this measure:

Previous Department = 
CALCULATE (
    MAX ( 'Table'[Department] ),
    OFFSET (
        -1,
        ALLEXCEPT ( 'Table', 'Table'[Display_Name] ),
        ORDERBY ( 'Table'[Effective_Date], ASC )
    )
)

 

danextian_0-1721201106776.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.
rajendraongole1
Super User
Super User

Hi @Anonymous - you can achieve this using calculated column dax

I have created index column from power query editor and used the function as below

PreviousDepartment =
VAR CurrentIndex = 'pvys'[Index]
VAR CurrentName = 'pvys'[Display_Name]
RETURN
    CALCULATE(
        MAX('pvys'[Department]),
        FILTER(
            'pvys',
            'pvys'[Display_Name] = CurrentName &&
            'pvys'[Index] = CurrentIndex - 1
        )
    )
 
rajendraongole1_0-1721190333101.png

 

in visual

rajendraongole1_1-1721190365491.png

 

Hope it helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





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

Proud to be a Super User!





Anonymous
Not applicable

Is it possible to use measure? Because the real data size is huge.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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