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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
IuteJV
Frequent Visitor

Conditional formatting based on previous row value

Hello

I have a problem I have not been able to crack. I have an audit table, where I need to display different data points and highlight those data points (different columns) that have been changed, when compared to a previous row. The example data I have provided, let's sa that it consists of 4 different regions and within each of those regions there are two different products. Both of the products will be updated in the system at the same time, nevertheless if one of them was not changed (nothing can be done regarding that, the system was built like that).

 

Row Number (example purpose only)CountryValid fromValid until

Product

Measure1-ageMeasure2 - percentageMeasure3-amount
1Country1Fri, 02 Feb 2024 15:10:28 Product1180%5000

2

Country1

Fri, 02 Feb 2024 15:10:28 Product2200%300
3Country2Fri, 02 Feb 2024 15:10:28 Product1180%15000
4Country2Fri, 02 Feb 2024 15:10:28 Product2200%90000
5Country3Fri, 26 Jan 2024 09:16:40 Product1180%400
6Country3Fri, 26 Jan 2024 09:16:40 Product2200%1000
7Country4Thu, 25 Jan 2024 14:21:44 Product1180%3000
8Country4Thu, 25 Jan 2024 14:21:44 Product2200%400
9Country1Sat, 17 Sep 2022 21:53:47Fri, 02 Feb 2024 15:10:28Product11810%5000
10Country1Sat, 17 Sep 2022 21:53:47Fri, 02 Feb 2024 15:10:28Product21815%300
11Country3Mon, 18 Sep 2023 11:14:43Fri, 26 Jan 2024 09:16:40Product1180%500
12Country3Mon, 18 Sep 2023 11:14:43Fri, 26 Jan 2024 09:16:40Product21810%1200
13Country2Tue, 09 Jan 2024 12:52:01Fri, 02 Feb 2024 15:10:28Product1185%10000
14Country2Tue, 09 Jan 2024 12:52:01Fri, 02 Feb 2024 15:10:28Product2180%70000
15Country4Mon, 01 Jan 2024 00:00:00Thu, 25 Jan 2024 14:21:44Product1180%3500
16Country4Mon, 01 Jan 2024 00:00:00Thu, 25 Jan 2024 14:21:44Product2180%400
17Country4Tue, 31 Jan 2023 16:25:35Mon, 01 Jan 2024 00:00:00Product1180%3500
18Country4Tue, 31 Jan 2023 16:25:35Mon, 01 Jan 2024 00:00:00Product2162%400
19Country2Fri, 24 Nov 2023 10:45:53Tue, 09 Jan 2024 12:52:01Product1165%15000
20Country2Fri, 24 Nov 2023 10:45:53Tue, 09 Jan 2024 12:52:01Product2160%90000
21Country1Sat, 17 Sep 2022 21:56:25Sat, 17 Sep 2022 21:53:47Product11810%8000
22Country1Sat, 17 Sep 2022 21:56:25Sat, 17 Sep 2022 21:53:47Product21612%400
23Country2Thu, 04 May 2023 22:02:51Fri, 24 Nov 2023 10:45:53Product1204%15000
24Country2Thu, 04 May 2023 22:02:51Fri, 24 Nov 2023 10:45:53Product2202%90000

The final outcome should be something like this. All of the highlighted values, are those values that had been changed from the pervious time.
IuteJV_0-1707818616818.png

Can you help a guy out to achieve this?

Best regards!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Here's a general idea how you can do this with OFFSET

 

lbendlin_0-1707873533614.png

The sorting was done to check that the formula works, and can be changed back to the row number (or whatever else you are planning to sort this by.

 

Age Change = 
var v = sum('Table'[Measure1-age])
var vp = CALCULATE(sum('Table'[Measure1-age]),OFFSET(-1,ALLSELECTED('Table'),
                                              ORDERBY([Row Number (example purpose only)]),
                                              PARTITIONBY('Table'[Country],'Table'[Product]),
                                              MATCHBY('Table'[Row Number (example purpose only)])))
return if(COALESCE(vp,v)<>v,"yellow")

 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Here's a general idea how you can do this with OFFSET

 

lbendlin_0-1707873533614.png

The sorting was done to check that the formula works, and can be changed back to the row number (or whatever else you are planning to sort this by.

 

Age Change = 
var v = sum('Table'[Measure1-age])
var vp = CALCULATE(sum('Table'[Measure1-age]),OFFSET(-1,ALLSELECTED('Table'),
                                              ORDERBY([Row Number (example purpose only)]),
                                              PARTITIONBY('Table'[Country],'Table'[Product]),
                                              MATCHBY('Table'[Row Number (example purpose only)])))
return if(COALESCE(vp,v)<>v,"yellow")

 

Thank you @lbendlin This works just great!

Helpful resources

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