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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

average open balance, a dax question

hello!

 

I have a dax question concerning average open balance. My data looks like this:

image.png

I have linked a date calendar table to my fact table. 

I have created an open balance measure:

CALCULATE(SUM('table'[transaction]), FILTER(ALLSELECTED(dim_Calendar), dim_Calendar[Date] <= MAX(dim_Calendar[Date]))
This gives me the correct open balance for every day on the calendar.
Now I would like to have an average value for open balance within a certain time period. I have tried way too long with no succes. Can someone help me or point in right direction? Thanks so much in advance!
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous , I think this measure might do what you are after:

Avg Balance = 
    VAR vFirstDate = FIRSTDATE(ALLSELECTED(_Date[Date]))
    VAR vLastDate = LASTDATE('_Date'[Date])
    RETURN
        AVERAGEX(
            CALCULATETABLE(
                '_Date'
                ,_Date[Date] >= vFirstDate
                , _Date[Date] <= vLastDate
            )
            ,[Open Balance]
        )

With your test data, here are the Avg Balance it gives for each day in Jan 2022. For the month of Jan 2022, the average balance is 4000 which I think it right

9 days @ 5000 = 45000

5 days @ 3000 = 15000

15 days @ 4000 = 60000

2 days @ 2000 = 4000

total = 124000 / 31 days = 4000

EylesIT_0-1655745082832.png

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Anonymous , I think this measure might do what you are after:

Avg Balance = 
    VAR vFirstDate = FIRSTDATE(ALLSELECTED(_Date[Date]))
    VAR vLastDate = LASTDATE('_Date'[Date])
    RETURN
        AVERAGEX(
            CALCULATETABLE(
                '_Date'
                ,_Date[Date] >= vFirstDate
                , _Date[Date] <= vLastDate
            )
            ,[Open Balance]
        )

With your test data, here are the Avg Balance it gives for each day in Jan 2022. For the month of Jan 2022, the average balance is 4000 which I think it right

9 days @ 5000 = 45000

5 days @ 3000 = 15000

15 days @ 4000 = 60000

2 days @ 2000 = 4000

total = 124000 / 31 days = 4000

EylesIT_0-1655745082832.png

 

Anonymous
Not applicable

Amazing! Thank you so much. Time for more dax training for me 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.