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
shubhra992
New Member

Unable to calculate the correct previous year revenue

Hi All,

 

I am facing an issue with my DAX expression to calculate the previous year revenue for all the contracts. I have in my table the invoice date for each cintract and calculated the previous year invoice date (mentioned as previous year). The DAX is working well if the contracts are still ongoing. However, if a contract ended the previous year, I am unable to calculate the correct previous year revenue as the expression is rejecting all the ccontracts that ended last year. I have posted my query below. Could you please help me identify the problem.

 

Thank you

 

 

Previous Rev =
Var _Prevdate= 'evenue'[Previous year invoice date]
VAR _MonthStartPrevDate = STARTOFMONTH('Revenue'[Previous year invoice date])
Return
CALCULATE(SUM('Revenue'[Revenue]),FILTER('Revenue','Revenue'[Invoice Date] >= _MonthStartPrevDate && 'Revenue'[Invoice Date] <= _Prevdate && 'Waterfall Revenue'[Contract ID]=EARLIER('Revenue'[Contract ID])))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @shubhra992 ,

Please update the formula of calculated column as below and check if it can return the expected result...

Previous Rev =
VAR _Prevdate = 'Revenue'[Previous year invoice date]
VAR _MonthStartPrevDate =
    STARTOFMONTH ( 'Revenue'[Previous year invoice date] )
RETURN
    CALCULATE (
        SUM ( 'Revenue'[Revenue] ),
        FILTER (
            ALL ( 'Revenue' ),
            'Revenue'[Invoice Date] >= _MonthStartPrevDate
                && 'Revenue'[Invoice Date] <= _Prevdate
                && 'Revenue'[Contract ID] = EARLIER ( 'Revenue'[Contract ID] )
        )
    )

 

If the above one can't help you figure out, please provide some raw data in your table 'Revenue' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @shubhra992 ,

Please update the formula of calculated column as below and check if it can return the expected result...

Previous Rev =
VAR _Prevdate = 'Revenue'[Previous year invoice date]
VAR _MonthStartPrevDate =
    STARTOFMONTH ( 'Revenue'[Previous year invoice date] )
RETURN
    CALCULATE (
        SUM ( 'Revenue'[Revenue] ),
        FILTER (
            ALL ( 'Revenue' ),
            'Revenue'[Invoice Date] >= _MonthStartPrevDate
                && 'Revenue'[Invoice Date] <= _Prevdate
                && 'Revenue'[Contract ID] = EARLIER ( 'Revenue'[Contract ID] )
        )
    )

 

If the above one can't help you figure out, please provide some raw data in your table 'Revenue' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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.

Top Solution Authors