Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Calculate Total Amount using Filter

I have a table that looks like this

 

And I want a measure that will calculate two things by Customer Name, so that I can put it in a matrix table.

 

1. Total Expected Amount: This will calculate the Total Expected Amount by each Customer Name using the data in the Expected Amount column e.g. Customer A should have total Expected Amount = 28,200

 

2. Total Amount Paid: This will calculate the Total Amount Paid by each Customer Name using the data in Amount Paid column by applying the filter below:

state= Paid & Status =  Paid by Customer or Paid by Agency or Paid by BU

OR

Expected Amount = Amount Paid

e.g. Customer F total Amount Paid should be = 138,015

CustomerApplication TitleInvoice TitleExpected AmountAmount PaidStateStatus
AAPP-0000001INV-EN-0000001                    1,000.00         1,500.00PaidPaid by Customer
AAPP-0000001INV-EN-0000002                    5,000.00         5,000.00PaidRefunded
AAPP-0000001INV-EN-0000003                       300.00   
AAPP-0000002INV-EN-0000004                       400.00             400.00PaidPaid by Agency
AAPP-0000003INV-EN-0000005                    4,000.00         4,500.00ActiveUnderPayment
AAPP-0000004INV-EN-0000006                    8,000.00       80,000.00ActiveOverpayment
AAPP-0000005INV-EN-0000007                       500.00             500.00PaidPaid by Customer
AAPP-0000006INV-EN-0000008                    9,000.00         9,000.00PaidPaid by Agency
BAPP-0000007INV-EN-0000009    
CAPP-0000008INV-EN-0000010                       200.00             200.00PaidPaid by Customer
CAPP-0000009INV-EN-0000011                    4,000.00         4,000.00PaidPaid by Agency
CAPP-0000010INV-EN-0000012                    3,500.00         3,500.00PaidPaid by Customer
DAPP-0000011INV-EN-0000013                    1,000.00             800.00ActiveUnderPayment
EAPP-0000012INV-EN-0000014                 23,000.00       23,000.00PaidPaid by Customer
FAPP-0000013INV-EN-0000015                 24,500.00       20,000.00ActiveUnderPayment
FAPP-0000014INV-EN-0000016                 23,000.00       23,000.00PaidPaid by Customer
FAPP-0000014INV-EN-0000017                 23,001.00       23,001.00PaidPaid by Agency
FAPP-0000014INV-EN-0000018                 23,002.00       23,002.00PaidPaid by Customer
FAPP-0000015INV-EN-0000019                 23,003.00       23,003.00PaidPaid by Agency
FAPP-0000016INV-EN-0000020                 23,004.00       23,004.00PaidPaid By BU
FAPP-0000017INV-EN-0000021                 23,005.00       23,005.00PaidPaid by Agency
GAPP-0000018INV-EN-0000022    

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,
    Thanks for Ashish_Mathur  rply.
    Here are my measures

    Total Expected Amount = 
    CALCULATE(
        SUM('Table'[Expected Amount]),
        ALLEXCEPT(
            'Table',
            'Table'[Customer]
        )
    )
    Total Amount Paid = 
    CALCULATE(
        SUM('Table'[Amount Paid]),
        FILTER(
            ALLEXCEPT(
                'Table',
                'Table'[Customer]
            ),
            'Table'[State] = "Paid" && 'Table'[Status] = "Paid by Customer" || 
            'Table'[State] = "Paid" && 'Table'[Status] = "Paid by Agency" ||
            'Table'[State] = "Paid" && 'Table'[Status] = "Paid by BU"
        )
    )

    Final output

    Best regards,
    Albert He

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

4 Replies

  • Hi,

    Try these measures

    Total expected amount = sum(Data[Expected amount])

    Total amount paid = calculate(sum(Data[amount paid]),Data[State]="Paid"&&Data[Status]<>"Refunded")

    Hope this helps.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Given the one to many relationship between a property and invoices, how would this work?

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        You confuse me to the hilt.  In the original question, there is no mention of more than 1 table so the question os building a relationship does not arise at all.  Furthermore, have you even tried my solution?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,
    Thanks for Ashish_Mathur  rply.
    Here are my measures

    Total Expected Amount = 
    CALCULATE(
        SUM('Table'[Expected Amount]),
        ALLEXCEPT(
            'Table',
            'Table'[Customer]
        )
    )
    Total Amount Paid = 
    CALCULATE(
        SUM('Table'[Amount Paid]),
        FILTER(
            ALLEXCEPT(
                'Table',
                'Table'[Customer]
            ),
            'Table'[State] = "Paid" && 'Table'[Status] = "Paid by Customer" || 
            'Table'[State] = "Paid" && 'Table'[Status] = "Paid by Agency" ||
            'Table'[State] = "Paid" && 'Table'[Status] = "Paid by BU"
        )
    )

    Final output

    Best regards,
    Albert He

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