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
Sumsar
Helper II
Helper II

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
Sumsar
Helper II
Helper II

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
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.

Top Solution Authors