Forum Discussion
Sum amount based on account range
- 2 years ago
Hi HAM
Would a measure like this help?
Total in Range = SUMX( ADDCOLUMNS( 'Account', "__amt", VAR _From = [From] VAR _To = [To] VAR _Res = CALCULATE( SUM( 'Entries'[Amount] ), FILTER( ALL( 'Entries' ), 'Entries'[Acc] >= _From && 'Entries'[Acc] <= _To ) ) RETURN _Res ), [__amt] )or a calculated column
Total in Range CC = CALCULATE( SUMX( ADDCOLUMNS( 'Account', "__amt", VAR _From = [From] VAR _To = [To] VAR _Res = CALCULATE( SUM( 'Entries'[Amount] ), FILTER( ALL( 'Entries' ), 'Entries'[Acc] >= _From && 'Entries'[Acc] <= _To ) ) RETURN _Res ), [__amt] ) )Let me know if you have any questions.
Sum of amount based on account range.pbix
HAM , You can first add one calculated column in Entry table using below method
Account Number =
VAR CurrentAcc = EntryTable[Acc]
RETURN
CALCULATE(
MAX('Account Table'[No]),
'Account Table'[From] <= CurrentAcc && (ISBLANK('Account Table'[To]) || CurrentAcc <= 'Account Table'[To])
)
Then you can create one measure for sum using
Total Amount =
CALCULATE(
SUM(EntryTable[Amount]),
ALLEXCEPT(EntryTable, EntryTable[Account Number])
)
Please accept as solution and give kudos if it helps
Thank you for your response but this doesn't work
- gmsamborn2 years ago
Super User
Hi HAM
Would a measure like this help?
Total in Range = SUMX( ADDCOLUMNS( 'Account', "__amt", VAR _From = [From] VAR _To = [To] VAR _Res = CALCULATE( SUM( 'Entries'[Amount] ), FILTER( ALL( 'Entries' ), 'Entries'[Acc] >= _From && 'Entries'[Acc] <= _To ) ) RETURN _Res ), [__amt] )or a calculated column
Total in Range CC = CALCULATE( SUMX( ADDCOLUMNS( 'Account', "__amt", VAR _From = [From] VAR _To = [To] VAR _Res = CALCULATE( SUM( 'Entries'[Amount] ), FILTER( ALL( 'Entries' ), 'Entries'[Acc] >= _From && 'Entries'[Acc] <= _To ) ) RETURN _Res ), [__amt] ) )Let me know if you have any questions.
Sum of amount based on account range.pbix