Forum Discussion

bgirish's avatar
bgirish
Frequent Visitor
8 years ago
Solved

Summning data from different rows

I've got a table called 'orders'   order_id, customer_id 1001, 5000 1002, 5432   and another 'order_detail' with multiple rows per order   order_detail_id, order_id, type, value 1, 1001, ite...
  • alexei7's avatar
    8 years ago

    Hi bgirish,

     

    Presuming you have the two tables joined by order_id in the relationships view, try the following:

     

    Revenue = CALCULATE(SUM(order_detail[value]),order_detail[type]="item")-CALCULATE(SUM(order_detail[value]),order_detail[type]="discount") 

    Hope that helps,

    Alex