Forum Discussion
Shubhshrsth143
1 year agoNew Member
Accrual Basis Rows splitting
I have connected database to power bi. i need to calculate accrual amount on the basis of start and expiry date of transaction splitted in month column every month. I have a file that does the same i...
DataNinja777
1 year agoSuper User
Hi Shubhshrsth143 ,
Accrued expenses are expenses that have been incurred but not yet paid; they are typically settled in the short term and removed from the balance sheet when paid or invoices are received and reclassifed to AP.
You can produce your required output of the accrued expenses which gets recorded with the passage of time by writing a dax measure like below:
Accrued expense recognition =
SUMX(
'Accrued expenses',
VAR StartDate = MAX('Accrued expenses'[Start date])
VAR EndDate = MIN('Accrued expenses'[End date])
// Get the number of days within the current month filter context
VAR DaysInMonth = COUNTROWS(
FILTER(
'Calendar',
'Calendar'[Date] >= StartDate &&
'Calendar'[Date] <= EndDate &&
'Calendar'[Date] >= STARTOFMONTH('Calendar'[Date]) &&
'Calendar'[Date] <= ENDOFMONTH('Calendar'[Date])
)
)
RETURN
IF(
StartDate <= MAX('Calendar'[Date]) &&
EndDate >= MIN('Calendar'[Date]),
'Accrued expenses'[Daily expense] * DaysInMonth,
BLANK()
)
)
Which will produce the visualization like below:
Additionally, cumulative accrued expense until invoice is received, will look like below:
Accrued expense cumulative =
SUMX(
'Accrued expenses',
VAR StartDate = 'Accrued expenses'[Start date]
VAR EndDate = 'Accrued expenses'[End date]
// Calculate the number of days from the start date up to the end date, within the cumulative range
VAR DaysInRange = COUNTROWS(
FILTER(
ALL('Calendar'),
'Calendar'[Date] >= StartDate &&
'Calendar'[Date] <= EndDate &&
'Calendar'[Date] <= MAX('Calendar'[Date]) // Cumulative up to the current calendar date in context
)
)
RETURN
IF(
StartDate <= MAX('Calendar'[Date]) && EndDate >= MIN('Calendar'[Date]),
'Accrued expenses'[Daily expense] * DaysInRange,
BLANK()
)
)
I've attached an example pbix file for your reference.
Best regards,