Forum Discussion

Croshay's avatar
Croshay
Frequent Visitor
5 months ago
Solved

SUM based on VAR value/ Subscription Revenue Total

I want to get a total revenue measure but am having issues. I have three tables Customers and Product and Date. Relevent Fields for Customer: Company Start Date Product ID A 1/1/2020 10 ...
  • cengizhanarslan's avatar
    5 months ago

    Please try the measure below:

    Revenue =
    SUMX (
        Customers,
        VAR _startDate    = Customers[Start Date]
        VAR _endDate      = MAX ( __Dates[Date] )
        VAR _productPrice =
            CALCULATE (
                MAX ( 'Product'[Price] ),
                'Product'[ID] = Customers[Product ID]
            )
        VAR _dateDifference =
            DATEDIFF ( _startDate, _endDate, MONTH )
        VAR _paymentMonths =
            IF ( _dateDifference >= 0, _dateDifference + 1, 0 )
        RETURN
            _paymentMonths * _productPrice
    )