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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ShantanuBakare
New Member

Calculate sum of invoices for which we received payment.

have folloiwng data set

Week NoRegioninvoice numberInvoice TypeBucket Balance Amount 
Wk1UKINV001Overdue[0-30] 100
Wk1CEINV002Overdue[46-60] 100
Wk1UKINV003Overdue[31-45] 100
Wk1UKINV004Overdue[46-60] 100
Wk1NAINV005Overdue[0-30] 100
Wk1CEINV006Overdue[0-30] 100
Wk1CEINV007Overdue[46-60] 100
Wk1NAINV008Overdue[31-45] 100
Wk1CEINV009Overdue[0-30] 100
Wk1CEINV010Overdue[46-60] 100
Wk2UKINV004Overdue[31-45] 100
Wk2CEINV005Overdue[0-30] 100
Wk2UKINV006Overdue[46-60] 100
Wk2UKINV007Overdue[31-45] 100
Wk2NAINV008Overdue[46-60] 100
Wk2CEINV009Overdue[0-30] 100
Wk2CEINV010Overdue[0-30] 100
Wk2NAINV011Overdue[46-60] 100
Wk2CEINV012Overdue[31-45] 100

 

I want to calculate Sum of balance amount for invoices which were there in Wk1 and are not in Wk2 (for Ex in above table sum of INV1, INV2 & INV3). Also want sum of newly created invoices in Wk2 such as INV11 & INV12.

I should be able to put it in matrix which will have region in rows or bucket.

2 REPLIES 2
daxer-almighty
Solution Sage
Solution Sage

[Inv Amt In WK1\WK2] =
var In_ = "Wk1"
var NotIn_ = "Wk2"
var InvoicesOfInterest =
    EXCEPT(
        CALCULATETABLE(
            DISTINCT( T[Invoice Number] ),
            T[Week No] = In_
        ),
        CALCULATETABLE(
            DISTINCT( T[Invoice Number] ),
            T[Week No] = NotIn_,
            ALL( T )
        )
    )
return
    CALCULATE(
        SUM( T[Balance Amount] ),
        InvoicesOfInterest
    )
    
// The second measure
[Inv Amt in WK2\WK1] =
var In_ = "Wk2"
var NotIn_ = "Wk1"
var InvoicesOfInterest =
    EXCEPT(
        CALCULATETABLE(
            DISTINCT( T[Invoice Number] ),
            T[Week No] = In_
        ),
        CALCULATETABLE(
            DISTINCT( T[Invoice Number] ),
            T[Week No] = NotIn_,
            ALL( T )
        )
    )
return
    CALCULATE(
        SUM( T[Balance Amount] ),
        InvoicesOfInterest
    )
ShantanuBakare
New Member

Tried creating folloiwng dax but it is not working

PaidInv = CALCULATE(SUM(Sheet1[Balance Amount in USD]),
FILTER(Sheet1,DISTINCT(Sheet1[invoice number])
&&Sheet1[Week No] in {"Wk1"}))
 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.