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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors