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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
StevenH417
Regular Visitor

Sum balances where reporting date is last day of previous year

I have a table that includes reporting dates and balances of all accounts for every day. I'm trying to create a measure that will sum all the balances in the table when the reporting date is the last day of the previous year without hard coding what that date is. On the report the user has a slicer where they can select which reporting date they want to view so if they selected 2023-02-15 then this measure would show the sum of balances where the reporting date is 2022-12-31. If they selected 2022 -05-15 then it would show for 2021-12-31. Could anyone help me write up the DAX for that?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Balance end of prev year =
VAR ChosenDate =
    SELECTEDVALUE ( 'Date'[Date] )
VAR EndPrevYear =
    DATE ( YEAR ( ChosenDate ) - 1, 12, 31 )
VAR Result =
    CALCULATE ( [sum of balances], 'Date'[Date] = EndPreYear )
RETURN
    Result

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

Try

Balance end of prev year =
VAR ChosenDate =
    SELECTEDVALUE ( 'Date'[Date] )
VAR EndPrevYear =
    DATE ( YEAR ( ChosenDate ) - 1, 12, 31 )
VAR Result =
    CALCULATE ( [sum of balances], 'Date'[Date] = EndPreYear )
RETURN
    Result

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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