Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin 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.
I am new to BI. How to get different from previous record both value and percentage.
For example my table as below
Product | Revenue | RptDate |
A | 100 | 1/1/2024 |
A | 200 | 3/7/2024 |
A | 150 | 7/8/2024 |
B | 300 | 1/1/2024 |
B | 420 | 3/7/2024 |
B | 250 | 7/8/2024 |
C | 300 | 1/1/2024 |
C | 250 | 3/7/2024 |
C | 600 | 7/8/2024 |
The output visual is as below,
I can do it in excel, but how to achieve it in BI. Thanks.
Solved! Go to Solution.
Hi @stanwang ,
You can create a custom column as below:-
Delta =
VAR _prev =
CALCULATE (
SUM ( 'Table (4)'[Revenue] ),
FILTER (
( 'Table (4)' ),
'Table (4)'[RptDate] < EARLIER ( [RptDate] )
&& 'Table (4)'[Product] = EARLIER ( 'Table (4)'[Product] )
)
)
RETURN
IF ( _prev <> BLANK (), [Revenue] - _prev )
and use this column in Matrix as below:-
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi @stanwang
1. Dynamic Solution:
My solution stands out as the only dynamic approach among those presented here. Adding a column renders other solutions static, leading to unexpected and inaccurate results when filters or slicers are applied. My solution utilizes a measure, ensuring its dynamic nature and seamless operation even when interactions are added to the report. Please note that you have marked an incorrect solution as the correct one. It displays an erroneous result. (I have highlighted the incorrect solution you marked in red in the attached image.)
More information about the differences between the measure and calculated column is here :
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
2. Total Row Error:
I acknowledge my oversight regarding the total row. It's essential to remember that unlike Excel, the total row in Power BI doesn't simply sum the values above it within the visualization. Instead, it performs the same calculation applied to each category but without their context. Therefore, errors can arise, as happened in my case, if proper analysis is not conducted.
I corrected the measure of the previous value :
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Hi,
PBI file attached.
Hope this helps.
@Ashish_Mathur It is awesome. This is the best solution, easy to understand and implement. Thank you.
You are welcome.
Hi @stanwang
In the first step, I recommend adding an index column by-product, using linked method
https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query
The result will look like:
Then you can create these measures:
pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
@Ritaf1983 Your method is complicated, but it works fine for me. Just curious about highlighted in red. Why it is not 170?
Hi @stanwang
1. Dynamic Solution:
My solution stands out as the only dynamic approach among those presented here. Adding a column renders other solutions static, leading to unexpected and inaccurate results when filters or slicers are applied. My solution utilizes a measure, ensuring its dynamic nature and seamless operation even when interactions are added to the report. Please note that you have marked an incorrect solution as the correct one. It displays an erroneous result. (I have highlighted the incorrect solution you marked in red in the attached image.)
More information about the differences between the measure and calculated column is here :
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
2. Total Row Error:
I acknowledge my oversight regarding the total row. It's essential to remember that unlike Excel, the total row in Power BI doesn't simply sum the values above it within the visualization. Instead, it performs the same calculation applied to each category but without their context. Therefore, errors can arise, as happened in my case, if proper analysis is not conducted.
I corrected the measure of the previous value :
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Happy to help 🙂
@stanwang you could also do this in Power Query using this method:
Referencing the Next Row in Power Query • My Online Training Hub
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi @stanwang ,
You can create a custom column as below:-
Delta =
VAR _prev =
CALCULATE (
SUM ( 'Table (4)'[Revenue] ),
FILTER (
( 'Table (4)' ),
'Table (4)'[RptDate] < EARLIER ( [RptDate] )
&& 'Table (4)'[Product] = EARLIER ( 'Table (4)'[Product] )
)
)
RETURN
IF ( _prev <> BLANK (), [Revenue] - _prev )
and use this column in Matrix as below:-
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
@Samarth_18Delta from 2nd to 1st is correct, but detal from 3rd to 2nd is not what I want.
Below is excel mockup.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
66 | |
65 | |
56 | |
39 | |
27 |
User | Count |
---|---|
85 | |
59 | |
45 | |
42 | |
39 |