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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
RogerSteinberg
Post Patron
Post Patron

Lookup previous value based on criteria from another column

Hi All,

 

I would like to get the value that preceedes based on the earlier date. The value needs to also match the group number.

 

My table looks like that:

+------------+-------+-------+----------------+
|    date    | group | value | previous value |  
+------------+-------+-------+----------------+
| 2019-02-02 |     2 |    50 |             45 |  
| 2019-02-02 |     1 |    60 |             80 |  
| 2019-01-18 |     2 |    45 |                |  
| 2019-01-18 |     1 |    80 |                | 

After looking different ressources online that ressemble my question I came up with the following query which gives me a blank column.:

RateChange = 
CALCULATE(
    VALUES(table[Rate]),
    FILTER(
        ALL(table),
        table[date] = EARLIER(table[date])-1  && table[group] = EARLIER(table[group])
    )
)

 I need help in getting the query to work as calculated column and measure.
Thank you !

2 ACCEPTED SOLUTIONS
ElenaN
Resolver V
Resolver V

Hello,

 

You can try the following modification marked with blue:

 

RateChange = 
CALCULATE(
    VALUES(table[Rate]),
    FILTER(
        ALL(table),
        table[date] < EARLIER(table[date])  && table[group] = EARLIER(table[group])
    )
)

Regards,

ElenaN

View solution in original post

v-chuncz-msft
Community Support
Community Support

@RogerSteinberg ,

 

You may refer to the post below.

https://community.powerbi.com/t5/Desktop/Finding-the-previos-occurrence-within-same-table-based-on-o...

Community Support Team _ Sam Zha
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

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@RogerSteinberg ,

 

You may refer to the post below.

https://community.powerbi.com/t5/Desktop/Finding-the-previos-occurrence-within-same-table-based-on-o...

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ElenaN
Resolver V
Resolver V

Hello,

 

You can try the following modification marked with blue:

 

RateChange = 
CALCULATE(
    VALUES(table[Rate]),
    FILTER(
        ALL(table),
        table[date] < EARLIER(table[date])  && table[group] = EARLIER(table[group])
    )
)

Regards,

ElenaN

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.