Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

SUM PAYMENT

Hi, I have some trouble trying to add a new column. The following table is an example of the data that I Have: 

 

PhonePlaceTotal OperationsTop visitedPayment CheckIn
222A5A101/01/20
222A5A202/01/20
222A5A303/01/20
222B5A403/01/20
222C5A403/01/20
224B2B403/01/20
224B2B403/01/20
225B1B403/01/20

 

I want to know how much a phone user paid in the top place, for example phone "222" has 5 transactions (each row), 3 places visited and the top visited is place "A". If I use: 

 

Payment = Calculate(SUM(Table1[Payment]),ALLEXCEPT(Table1,[Phone]))


I get for user "222" a total payment of 13. But I want the total payment in place A, that is 6. 

 

Thank you. 

  • hi  Anonymous 

    Use this formula to create a new column:

    Result = CALCULATE(SUM(Table1[Payment]),FILTER(Table1,Table1[Place]=EARLIER(Table1[Top visited])&&Table1[Phone]=EARLIER(Table1[Phone])))

    result:

     

    Regards,

    Lin

4 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi

      It worked, thank you. 

      But I have another issue, I want a column with the subtotal of A for all rows. 
      Is that possible? Thank you

      • v-lili6-msft's avatar
        v-lili6-msft
        Icon for Community Support rankCommunity Support

        hi  Anonymous 

        Use this formula to create a new column:

        Result = CALCULATE(SUM(Table1[Payment]),FILTER(Table1,Table1[Place]=EARLIER(Table1[Top visited])&&Table1[Phone]=EARLIER(Table1[Phone])))

        result:

         

        Regards,

        Lin

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Anonymous ,

     

     

    If you want to create a Column.

     

    Top Place1 =
    SUMX (
        FILTER (
            ALL (
                'Table'[Phone],
                'Table'[Place],
                'Table'[Phone],
                'Table'[Payment ]
            ),
            'Table'[Place] = 'Table'[Top visited]
        ),
        'Table'[Payment ]
    )

     

     

     

    Regards,
    Harsh Nathani

    Appreciate with a Kudos!! (Click the Thumbs Up Button)
    Did I answer your question? Mark my post as a solution!