Forum Discussion

atad's avatar
atad
Frequent Visitor
7 years ago
Solved

Trailing 12 Average Balance (Measure based on another measure)

Hi,  

I am still new to DAX.  I have a table that contains general ledger account transactions: account number, date, value.  I also have a date table.  the fiscal year starts on May 1st, ends on April next calendar year (12 fiscal period).  For each gl account, there is an opening balance on May 1st.  At last day of each month, there is an amount representing the total change of the month.  

 

Now I want to calculate the average balance over the past 12 fiscal period.  Trick part is at first I need to create a measure that calculates the ending balance at each fiscal period.  I was able to create that:

Accumu_Balance =
CALCULATE (
    SUM ( Trsansactions[Value] ),
    FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
)
 
I verified that is correct.  However I then encountered issues when creating a measure for the sum of the trailing 12 accumu_balance.  below is the measure for my second formula:
Total_Trailing12Period =
CALCULATE (
    [Accumu_Balance],
    DATESINPERIOD ( 'Date'[Date], LASTDATE ( 'Date'[Date] ), -12, MONTH )
)
However, the result is not what I expected.  The result is the same as the Accumu_Balance.  Can someone help with the DAX on the 2nd meausre?  Is it possible to sum the measure based on another measure?
Below is the transaction table and the result of the measures.
I can post the pbx file, but seems couldn't find a place to attach the file.
 
Thanks in advance!
atad
 

 

 

13 Replies