Forum Discussion

newkingdom's avatar
newkingdom
Frequent Visitor
4 years ago
Solved

Get only the payment amount from the same table

I have a basic table with a sales Id, Amount, Type activity. I want to create a new column in the table which will just return the Payments. So type = Payment, otherwise it will return a 0 for the other types. It should be based on id and the result set should look like below.

 

IdAmountType  Payment AMount     
12Payment  2      
13Refun  0      
16Payment  6      
24Payment  4      
24Refund  0      
26Refund  0      
36Something  0     
34Refund  0      
31Payment  1      
41Payment  1      
42Something  0     
45Something  0     
410Payment  10     

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi newkingdom 

     

    You can create a calculated column in this case:

    Payment Amount  = IF(
                                          TableName[Type] = "Payment",

                                           TableName[Amount], 0)

    I just tested this on my data and it worked. If the data-type of Amount is Number use 0, otherwise use "0"

     

    If you think my solution worked , please 'Accept' it as a solution and give it a like.

     

    Thanks,

    Mahesh

3 Replies

  • jppv20's avatar
    jppv20
    Solution Sage

    Hi newkingdom ,

     

    Try this:

     

    Payment_Amount = IF('Table'[Type]="Payment",'Table'[Amount],0)
     
    If I answered your question, please mark it as a solution to help other members find it more quickly.
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi newkingdom 

     

    You can create a calculated column in this case:

    Payment Amount  = IF(
                                          TableName[Type] = "Payment",

                                           TableName[Amount], 0)

    I just tested this on my data and it worked. If the data-type of Amount is Number use 0, otherwise use "0"

     

    If you think my solution worked , please 'Accept' it as a solution and give it a like.

     

    Thanks,

    Mahesh