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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
jal1aaa
Frequent Visitor

How to calculate the difference in values between two data rows in the same table

I have a table with data for multiple periods and want to calculate the difference between two periods based on user selection. For example, I have a table where different sales teams update their forecasted sales each month

Sales TeamForecastForecast Date
Northeast1000Jan-21
Southeast1200Jan-21
Midwest800Jan-21
Northwest900Jan-21
Southwest700Jan-21
Northeast950Feb-21
Southeast1300Feb-21
Midwest850Feb-21
Northwest950Feb-21
Southwest750Feb-21
Northeast950Mar-21
Southeast1250Mar-21
Midwest875Mar-21
Northwest900Mar-21
Southwest750Mar-21

 

I would like to create a table where the user selects two forecast dates and the table shows the difference between those two forecasts and ONLY includes records that have a difference.  For example, the output could select Mar 21 and Feb 21 and get the following output

Forecast date 1Forecast date 2  
21-Feb21-Mar  
    
Sales TeamForecast 1Forecast 2Change
Southeast13001250-50
Midwest85087525
Northwest950900-50
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jal1aaa ,

I created a sample pbix file for you, please check whether that is what you want. Please find the attachment for more details.

1. Create two dimension table: Forecast date 1 table and Forecast date 2 table using below formula and create two date slicers base on the date field in these two tables

Forecast date 1 = VALUES('Table'[Forecast Date])
Forecast date 2 = VALUES('Table'[Forecast Date])

yingyinr_1-1628142912386.png

2. Create the below measures to get the forecast1, forecast2 and change

Forecast 1 = 
CALCULATE (
    SUM ( 'Table'[Forecast] ),
    FILTER (
        'Table',
        'Table'[Forecast Date] = SELECTEDVALUE ( 'Forecast date 1'[Forecast Date] )
    )
)
Forecast 2 = 
CALCULATE (
    SUM ( 'Table'[Forecast] ),
    FILTER (
        'Table',
        'Table'[Forecast Date] = SELECTEDVALUE ( 'Forecast date 2'[Forecast Date] )
    )
)
Change = [Forecast 1]-[Forecast 2]

3. Create a table visual and apply the visual level filter with the condition: Change is not 0 just as shown in below screenshot

yingyinr_0-1628142890469.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @jal1aaa ,

I created a sample pbix file for you, please check whether that is what you want. Please find the attachment for more details.

1. Create two dimension table: Forecast date 1 table and Forecast date 2 table using below formula and create two date slicers base on the date field in these two tables

Forecast date 1 = VALUES('Table'[Forecast Date])
Forecast date 2 = VALUES('Table'[Forecast Date])

yingyinr_1-1628142912386.png

2. Create the below measures to get the forecast1, forecast2 and change

Forecast 1 = 
CALCULATE (
    SUM ( 'Table'[Forecast] ),
    FILTER (
        'Table',
        'Table'[Forecast Date] = SELECTEDVALUE ( 'Forecast date 1'[Forecast Date] )
    )
)
Forecast 2 = 
CALCULATE (
    SUM ( 'Table'[Forecast] ),
    FILTER (
        'Table',
        'Table'[Forecast Date] = SELECTEDVALUE ( 'Forecast date 2'[Forecast Date] )
    )
)
Change = [Forecast 1]-[Forecast 2]

3. Create a table visual and apply the visual level filter with the condition: Change is not 0 just as shown in below screenshot

yingyinr_0-1628142890469.png

Best Regards

parry2k
Super User
Super User

@jal1aaa solution is attached, you can tweak it as you see fit.

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Kudoed Authors