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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DAX Balance + Opening issues

Hi,

 

I am trying to calculate a YTD Balance based on a Finance transactions table. The table contains daily balances for all accounts AND a year opening balance for all accounts for all years. The later part is giving me a headache. My working formula so far:

 

BalanceSum(YTD) =
VAR LastDateAllCompanies =
    CALCULATETABLE (
        LASTNONBLANK (
            'CalendarPosting'[Date];
            COUNTROWS ( RELATEDTABLE ( FinanceTransactions ) )
        );
        ALL ( FinanceTransactions[CompanyID] )
    )
VAR Result =
    CALCULATE ( [BalanceSum]; LastDateAllCompanies )
RETURN
    Result
 
To this formula I need to add the opening balances for all accounts for a given year. the Finance transactions table has a true/false column to indicate if its an opening balance.
 
Any suggestions on how to apply this?
1 REPLY 1
Anonymous
Not applicable

I think I am closing in on the solution, but the numbers are still not adding up (but close):

 

BalanceSum(YTD) =
VAR OpeningAllCompanies =
    CALCULATE (
        [BalanceSum];
        FIRSTDATE ( 'Calendar'[Date] );
        FinanceTransactions[Opening] = TRUE
    )
VAR LastDateAllCompanies =
    CALCULATETABLE (
        LASTNONBLANK (
            'Calendar'[Date];
            COUNTROWS ( RELATEDTABLE ( FinanceTransactions ) )
        );
        ALL ( FinanceTransactions[CompanyID] )
    )
VAR Result =
    CALCULATE ( [BalanceSum]; LastDateAllCompanies ) + OpeningAllCompanies
RETURN
    Result
 
I thought this a fairly common scenario in Finance reporting, but is seems to be more complex than I first assumed.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.