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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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