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
GT1PowerBi
New Member

General Comments

Hi

 

I have the below data, and i need a custom column to calculate the previous days value based on the "product" and "NewOrExistingMember" filter. There are multiple Products and also multiple "NewOrExistingMember" selections

 

Previous Days Value.JPG

 

Any help would be much appreciated!

🙂

 

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

@GT1PowerBi,

 

In DAX you can’t reference the previous row in any way because there is no order to the rows, So fi you need to get previous row, you can create a rank column, and then use LOOKUPVALUE function to get it.

Sample data and DAX for you reference.

Rank =
RANKX (
    FILTER (
        Table1,
        Table1[Group] = EARLIER ( Table1[Group] )
            && Table1[Group2] = EARLIER ( Table1[Group2] )
    ),
    Table1[Amount],
    ,
    ASC
)
PreviousValue =
LOOKUPVALUE (
    Table1[Amount],
    Table1[Group], Table1[Group],
    Table1[Group2], Table1[Group2],
    Table1[Rank], Table1[Rank] - 1
)

Capture.PNG

 

Regards,

Charlie Liao

 

View solution in original post

1 REPLY 1
v-caliao-msft
Microsoft Employee
Microsoft Employee

@GT1PowerBi,

 

In DAX you can’t reference the previous row in any way because there is no order to the rows, So fi you need to get previous row, you can create a rank column, and then use LOOKUPVALUE function to get it.

Sample data and DAX for you reference.

Rank =
RANKX (
    FILTER (
        Table1,
        Table1[Group] = EARLIER ( Table1[Group] )
            && Table1[Group2] = EARLIER ( Table1[Group2] )
    ),
    Table1[Amount],
    ,
    ASC
)
PreviousValue =
LOOKUPVALUE (
    Table1[Amount],
    Table1[Group], Table1[Group],
    Table1[Group2], Table1[Group2],
    Table1[Rank], Table1[Rank] - 1
)

Capture.PNG

 

Regards,

Charlie Liao

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.