Forum Discussion
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] ) )
)Total_Trailing12Period =
CALCULATE (
[Accumu_Balance],
DATESINPERIOD ( 'Date'[Date], LASTDATE ( 'Date'[Date] ), -12, MONTH )
)
13 Replies
- TomMartens
Super User
Hey,
please provide an xlsx that contains sample data in one sheet and expected result in another sheet, upload the file to onedrive or dropbox and share the link.
Regards,
Tom- atadFrequent Visitor
First time to use drop box...below are the link to the files, first contains the excel file and expected result.
second is the pbix file.
Thanks,
https://www.dropbox.com/s/vsbk5hqxzvagtbd/BI%20Files.xlsx?dl=0
https://www.dropbox.com/s/sixqiwshxpzriep/trailing12Period_Balance.pbix?dl=0
- v-cherch-msft
Microsoft Employee
Hi atad
You may try below measure and drag Year and Month column into the visual.
Total_Trailing12Period = CALCULATE ( SUM ( Trsansactions[Value] ), DATESINPERIOD ( 'Date'[Date], LASTDATE ( 'Date'[Date] ), -12, MONTH ) )Regards,