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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gmasta1129
Helper III
Helper III

Difference in sales from previous year end date to current year month end dates

Hello,

 

My report contains the following columns: 

 

1. Month End Date (ex: 12/31/2024, 1/31/2025, 2/28/2025 etc.)

2. Portfolio Code

3. Sales Amount

4. Difference (new calculated column)

 

I would like to create a table which shows the difference in sales between each month of this year to the previous year end date (12/31/2024) by each portfolio code.  I need help with the formula for the "Difference" column.  

 

Please see example below for table I am looking to  create.  

 

Portfolio CodeMonth End Date Sales amount Difference
12345612/31/2024     5,000,000.00 
1234561/31/2025     4,000,000.00         (1,000,000.00)
1234562/28/2025   15,000,000.00         10,000,000.00
1234563/31/2025     2,000,000.00         (3,000,000.00)
1234564/31/2025   13,000,000.00           8,000,000.00
1234565/31/2025   18,000,000.00         13,000,000.00
1 ACCEPTED SOLUTION

Hi

If more than 5 years, i'd suggest you use measures based on your evaluation contexts in actual report. 

If you still prefer to use calculated columns, yes you can generalize it by updating variables.

VAR CurrentPortfolio = 'SalesTable'[Portfolio Code]
VAR CurrentDate = 'SalesTable'[Month End Date]
VAR CurrentYear = YEAR(CurrentDate)
VAR PreviousYearEnd = DATE(CurrentYear - 1, 12, 31)

Then replace the 'DATE(2024, 12, 31)' with 'PreviousYearEnd'

Hope this helps~

View solution in original post

6 REPLIES 6
v-karpurapud
Community Support
Community Support

Hi @gmasta1129 

I wanted to check if you’ve had a chance to review the information provided. If you have any further questions, please let us know. Has your issue been resolved? If not, please share more details so we can assist you further.

Thank You.

v-karpurapud
Community Support
Community Support

Hi @gmasta1129 

We have not yet heard back from you about whether the response addressed your query. If it did not, please share more details so we can assist you more effectively.

 

Thank You.

v-karpurapud
Community Support
Community Support

Hi @gmasta1129 

Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @MasonMA  for sharing valuable insights.


Could you please confirm if your query has been resolved by the provided solution? This will help other community members solve similar problems faster.

Thank you.

 

gmasta1129
Helper III
Helper III

Hello @MasonMA , 

Thank you for the quick response. I appreciate it.   

 

The above table I created contains sample data.  The full file contains 5 years + of data. 

 

Is it possible to change this part of the formula (see screenshot below) so its not set to 12/31/2024 but each year end date? For example, I'll need to compare 12/31/2023 with each month end in 2024, and 12/31/2022 with each month end in 2023, and 12/31/2021 with each month end in 2022.

    'SalesTable'[Month End Date] = DATE(2024, 12, 31)

 

 

Hi

If more than 5 years, i'd suggest you use measures based on your evaluation contexts in actual report. 

If you still prefer to use calculated columns, yes you can generalize it by updating variables.

VAR CurrentPortfolio = 'SalesTable'[Portfolio Code]
VAR CurrentDate = 'SalesTable'[Month End Date]
VAR CurrentYear = YEAR(CurrentDate)
VAR PreviousYearEnd = DATE(CurrentYear - 1, 12, 31)

Then replace the 'DATE(2024, 12, 31)' with 'PreviousYearEnd'

Hope this helps~

MasonMA
Solution Sage
Solution Sage

@gmasta1129 

 

Hi, build a new column with below DAX

Difference = 
VAR CurrentPortfolio = 'SalesTable'[Portfolio Code]

VAR BaselineSales =
    CALCULATE(
        MAX('SalesTable'[Sales Amount]),
        FILTER(
            'SalesTable',
            'SalesTable'[Month End Date] = DATE(2024, 12, 31)
            && 'SalesTable'[Portfolio Code] = CurrentPortfolio
        )
    )

RETURN
    'SalesTable'[Sales Amount] - BaselineSales

MasonMA_0-1752001738632.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Kudoed Authors