Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
snaseem
Helper I
Helper I

Calculation between Rows with conditions

I have below sample dataset where I am looking for compute outstaning balances.

Invoice is issued against certain services with due date to pay, and cash receipt is issued when we receive the cash against respective invoice(s). It does not has to be per invoice calculation, but overall outstanding balance is fine. There could be instances when we receive the full or partial/no payments.

 

trans_dateTrans_typeInvoice #Due DateAmount
4/24/2023Invoice1015/24/2023100
4/24/2023Invoice2025/24/2023200
4/24/2023Invoice3015/24/2023300
4/24/2023Invoice4015/24/2023400
4/24/2023Invoice5015/24/2023500
6/13/2023Cash Receipt1017/13/2023-100
6/13/2023Cash Receipt2027/13/2023-200
6/13/2023Cash Receipt3017/13/2023-300
6/13/2023Cash Receipt4017/13/2023-400
6/13/2023Cash Receipt5017/13/2023-400

 

Need help how to achieve this. 

5 REPLIES 5
Anonymous
Not applicable

Hi @snaseem 

You can refer to the following calculated column

Differ =
VAR sum_invoice =
    SUMX ( FILTER ( 'Table', [Trans_type] = "Invoice" ), [Amount] )
VAR sum_cash =
    SUMX ( FILTER ( 'Table', [Trans_type] = "Cash Receipt" ), [Amount] )
RETURN
    sum_invoice + sum_cash

Output

vxinruzhumsft_0-1692252733703.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Bmejia
Super User
Super User

Can yo just create a matrix table and drag and drop the Invoice # to Rows, Trans Type to Columns and Amount to Values.  The total will give you the outstanding balance

 


 Updating Media

 

Can we do this with the help of dax? I may need to add some other analysis as well such as avg time to pay the invoice etc.

yes, but if you want to actually type the dax formulas it be something like this 

Invoice = CALCULATE(SUM('Sample'[Amount]),'Sample'[Trans_type]="Invoice")
Cash Receipt = CALCULATE(SUM('Sample'[Amount]),'Sample'[Trans_type]="Cash Receipt")
Outstanding = [Invoice]-[Cash Receipt]
Average = CALCULATE(AVERAGE('Sample'[Amount]))
snaseem
Helper I
Helper I

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.