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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Taranggupta
New Member

How to get previous row value for text column.

Hi,

 

I would like to get the previous row value for a text column using DAX.

 

Example: Text_column

                    A

                    B

                    C

 

Expected Output: 

             Text_column, Previous_value

                    A                    NULL

                    B                       A

                    C                       B

 

Please let me know incase of any clarification.

 

Thanks in Advance.

1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Taranggupta

 

In DAX, there's no order internally for records in table. You have to add an index column in your table. 

 

22.PNG

 

PreviousText = CALCULATE(MAX(Table1[Text]),FILTER(Table1,Table1[Index]=EARLIER(Table1[Index])-1))

234.PNG

 

Regards,

 

 

View solution in original post

3 REPLIES 3
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Taranggupta

 

In DAX, there's no order internally for records in table. You have to add an index column in your table. 

 

22.PNG

 

PreviousText = CALCULATE(MAX(Table1[Text]),FILTER(Table1,Table1[Index]=EARLIER(Table1[Index])-1))

234.PNG

 

Regards,

 

 

Anonymous
Not applicable

Hi, 

 

@v-sihou-msft I am trying to replicate this and have added the index column, but getting a row context error from the EARLIER function onwards:

 

previous index = CALCULATE(MAX('Curso Académico'[Curso]);FILTER('Curso Académico';'Curso Académico'[Index]=EARLIER('Curso Académico'[Index]))


Row context error.PNG

 

Any ideas what I'm doing wrong?

 

Thanks!

 

...

is the -1 missing at the end? 

 

previous index = CALCULATE(MAX('Curso Académico'[Curso]);FILTER('Curso Académico';'Curso Académico'[Index]=EARLIER('Curso Académico'[Index])-1))

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 Kudoed Authors