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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Previous Value Using DAX

Capture.PNG

2 ACCEPTED SOLUTIONS
edhans
Community Champion
Community Champion

EDIT: Better way with no index, but I'm leaving my previous reply there. The Index method would allow you to move up/down by any number of rows you wish. Below will only move up to the previous date, but doesn't require an index to do this.
Use this calculated column (final edit - got rid of EARLIER altogether - Variables are better - didn't upload new image, so you can see the earlier EARLIER formula):

 

Previous 2 = 
VAR CurrentDate = Data[Date]
VAR PreviousDate =
    CALCULATE(
        LASTDATE(Data[Date]),
        FILTER(Data,
        Data[Date] < CurrentDate
        )
    )
RETURN
CALCULATE(
    MAX(Data[Users]),
    FILTER(
        Data,
        Data[Date] = PreviousDate
    )
)

 


20200214 12_58_14-Untitled - Power BI Desktop.png

Index method:

If you can create an Index column in Power Query this will help.

  1. In Power Query, sort your date column ascending
  2. On the Add Columns tab, click on Add Index Column. Doesn't matter if it starts with 0 or 1.
  3. Close and load the table.

 

Then Add this custom column in the table:

 

 

 

Previous = 
CALCULATE(
    MAX(Data[Users]),
    FILTER(
        Data,
        Data[Index] = EARLIER(Data[Index],1) -1
    )
)

 

 

 

You'll have this:
20200214 12_45_26-Untitled - Power BI Desktop.png



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

First, add a [index] column in Edit Queries;

Second, create the measure:

Measure 4 = 
VAR x = 
CALCULATE(
    MIN(Sheet2[Users]),
    FILTER(
        ALLSELECTED(Sheet2),
        Sheet2[Date] < MAX(Sheet2[Date]) && Sheet2[Index] = MAX(Sheet2[Index]) + 1
    )
)
RETURN
IF(
    x = BLANK(),
    0,
    x
)

d5.PNG

 

Best regards,
Lionel Chen

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

 

View solution in original post

4 REPLIES 4
Mejía_Sayabé
New Member

This work for me, thank you sir

v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

First, add a [index] column in Edit Queries;

Second, create the measure:

Measure 4 = 
VAR x = 
CALCULATE(
    MIN(Sheet2[Users]),
    FILTER(
        ALLSELECTED(Sheet2),
        Sheet2[Date] < MAX(Sheet2[Date]) && Sheet2[Index] = MAX(Sheet2[Index]) + 1
    )
)
RETURN
IF(
    x = BLANK(),
    0,
    x
)

d5.PNG

 

Best regards,
Lionel Chen

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

 

edhans
Community Champion
Community Champion

EDIT: Better way with no index, but I'm leaving my previous reply there. The Index method would allow you to move up/down by any number of rows you wish. Below will only move up to the previous date, but doesn't require an index to do this.
Use this calculated column (final edit - got rid of EARLIER altogether - Variables are better - didn't upload new image, so you can see the earlier EARLIER formula):

 

Previous 2 = 
VAR CurrentDate = Data[Date]
VAR PreviousDate =
    CALCULATE(
        LASTDATE(Data[Date]),
        FILTER(Data,
        Data[Date] < CurrentDate
        )
    )
RETURN
CALCULATE(
    MAX(Data[Users]),
    FILTER(
        Data,
        Data[Date] = PreviousDate
    )
)

 


20200214 12_58_14-Untitled - Power BI Desktop.png

Index method:

If you can create an Index column in Power Query this will help.

  1. In Power Query, sort your date column ascending
  2. On the Add Columns tab, click on Add Index Column. Doesn't matter if it starts with 0 or 1.
  3. Close and load the table.

 

Then Add this custom column in the table:

 

 

 

Previous = 
CALCULATE(
    MAX(Data[Users]),
    FILTER(
        Data,
        Data[Index] = EARLIER(Data[Index],1) -1
    )
)

 

 

 

You'll have this:
20200214 12_45_26-Untitled - Power BI Desktop.png



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

This was SO helpful, thank you!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.