Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi all
I have data where payments are made against invoices. Every invoice can have one or many payment vouchers.
I have written 2 measures
OpenBal = CALCULATE([Billings] - [Collections],
FILTER(ALL(MasterDate[Date]),MasterDate[Date]<MIN(MasterDate[Date])))
ClosingBal =
var closebal = CALCULATE([Billings] - [Collections] ,
FILTER(ALL(MasterDate[Date]),MasterDate[Date]<=MAX([Date])))
But when brought in a matrix, the measure calculates line wise and the result shows like this -
March | ||||
OpenBal | Billings | Collections | ClosingBal | |
Invoice1 | 30,000 | 30,000 | 0 | |
Voucher1 | 30,000 | 18,000 | 12,000 | |
Voucher2 | 30,000 | 12,000 | 18,000 |
Both Voucher1 and Voucher2 are marked against the same invoice.
Even though total shows 0 here, the individual balances are carried over in the next few months. How can I rectify this.
Any advice/suggestion highly appreciated.
@tamerj1 @Greg_Deckler
@Rakshana Hi! You can use SUMX and FILTER to iterate through each invoice and its associated vouchers to calculate the open balance correctly:
OpenBal =
SUMX (
FILTER (
ALL ( 'YourTableName' ),
'YourTableName'[InvoiceID] = EARLIER ( 'YourTableName'[InvoiceID] )
&& 'YourTableName'[VoucherDate] < EARLIER ( 'YourTableName'[VoucherDate] )
),
'YourTableName'[Billings] - 'YourTableName'[Collections]
)
ClosingBal =
SUMX (
FILTER (
ALL ( 'YourTableName' ),
'YourTableName'[InvoiceID] = EARLIER ( 'YourTableName'[InvoiceID] )
&& 'YourTableName'[VoucherDate] <= MAX ( 'YourTableName'[VoucherDate] )
),
IF ( 'YourTableName'[Collections] < 0, 0, 'YourTableName'[Billings] - 'YourTableName'[Collections] )
)
Try, BBF
Hey thank you for your response.
But this throws a syntax error for EARLIER
Is there any other way to calculate Opening and Closing balance without it forming a circular dependency.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
13 | |
11 | |
10 | |
10 |