Forum Discussion
Leggies
4 years agoFrequent Visitor
Measure with historical aging data
Hi community, Over the last few days I have been struggling with the following issue: For my company I need to divide the accounts receivable by aging (<30 days, 30-60 days, 60-90 days, 90+ da...
- 4 years ago
DEFINE MEASURE Accounts[AR Total] = SUM( Accounts[AR] ) MEASURE 'Account Categories'[# Accounts (This Week)] = var CountOfAccountsInSelectedCategories = sumx( 'Account Categories', var LowerEndInclusive = 'Account Categories'[Lower End] var UpperEndExclusive = 'Account Categories'[Upper End] var CountOfAccounts = CALCULATE( DISTINCTCOUNT( Accounts[Relation] ), keepfilters( LowerEndInclusive <= Accounts[Days Open this week] ), keepfilters( Accounts[Days Open this week] < UpperEndExclusive ) ) return CountOfAccounts ) return CountOfAccountsInSelectedCategories MEASURE 'Account Categories'[AR Total (Last Week)] = var ARTotal = sumx( 'Account Categories', var LowerEndInclusive = 'Account Categories'[Lower End] var UpperEndExclusive = 'Account Categories'[Upper End] var AccountsTotal = CALCULATE( [AR Total], keepfilters( LowerEndInclusive <= Accounts[Days Open last week] ), keepfilters( Accounts[Days Open last week] < UpperEndExclusive ) ) return AccountsTotal ) return ARTotal MEASURE 'Account Categories'[AR Total (This Week)] = var ARTotal = sumx( 'Account Categories', var LowerEndInclusive = 'Account Categories'[Lower End] var UpperEndExclusive = 'Account Categories'[Upper End] var AccountsTotal = CALCULATE( [AR Total], keepfilters( LowerEndInclusive <= Accounts[Days Open this week] ), keepfilters( Accounts[Days Open this week] < UpperEndExclusive ) ) return AccountsTotal ) return ARTotal MEASURE 'Account Categories'[# Accounts (Last Week)] = var CountOfAccountsInSelectedCategories = sumx( 'Account Categories', var LowerEndInclusive = 'Account Categories'[Lower End] var UpperEndExclusive = 'Account Categories'[Upper End] var CountOfAccounts = CALCULATE( DISTINCTCOUNT( Accounts[Relation] ), keepfilters( LowerEndInclusive <= Accounts[Days Open last week] ), keepfilters( Accounts[Days Open last week] < UpperEndExclusive ) ) return CountOfAccounts ) return CountOfAccountsInSelectedCategoriesAnd here's the Account Categories table:
Note the intervals are left-closed-right-open. You can have it the other way round but you'll have to adjust the measures. It's easy.
daXtreme
Solution Sage
4 years agoDEFINE
MEASURE Accounts[AR Total] = SUM( Accounts[AR] )
MEASURE 'Account Categories'[# Accounts (This Week)] =
var CountOfAccountsInSelectedCategories =
sumx(
'Account Categories',
var LowerEndInclusive = 'Account Categories'[Lower End]
var UpperEndExclusive = 'Account Categories'[Upper End]
var CountOfAccounts =
CALCULATE(
DISTINCTCOUNT( Accounts[Relation] ),
keepfilters( LowerEndInclusive <= Accounts[Days Open this week] ),
keepfilters( Accounts[Days Open this week] < UpperEndExclusive )
)
return
CountOfAccounts
)
return
CountOfAccountsInSelectedCategories
MEASURE 'Account Categories'[AR Total (Last Week)] =
var ARTotal =
sumx(
'Account Categories',
var LowerEndInclusive = 'Account Categories'[Lower End]
var UpperEndExclusive = 'Account Categories'[Upper End]
var AccountsTotal =
CALCULATE(
[AR Total],
keepfilters( LowerEndInclusive <= Accounts[Days Open last week] ),
keepfilters( Accounts[Days Open last week] < UpperEndExclusive )
)
return
AccountsTotal
)
return
ARTotal
MEASURE 'Account Categories'[AR Total (This Week)] =
var ARTotal =
sumx(
'Account Categories',
var LowerEndInclusive = 'Account Categories'[Lower End]
var UpperEndExclusive = 'Account Categories'[Upper End]
var AccountsTotal =
CALCULATE(
[AR Total],
keepfilters( LowerEndInclusive <= Accounts[Days Open this week] ),
keepfilters( Accounts[Days Open this week] < UpperEndExclusive )
)
return
AccountsTotal
)
return
ARTotal
MEASURE 'Account Categories'[# Accounts (Last Week)] =
var CountOfAccountsInSelectedCategories =
sumx(
'Account Categories',
var LowerEndInclusive = 'Account Categories'[Lower End]
var UpperEndExclusive = 'Account Categories'[Upper End]
var CountOfAccounts =
CALCULATE(
DISTINCTCOUNT( Accounts[Relation] ),
keepfilters( LowerEndInclusive <= Accounts[Days Open last week] ),
keepfilters( Accounts[Days Open last week] < UpperEndExclusive )
)
return
CountOfAccounts
)
return
CountOfAccountsInSelectedCategoriesAnd here's the Account Categories table:
Note the intervals are left-closed-right-open. You can have it the other way round but you'll have to adjust the measures. It's easy.