Forum Discussion

soniajs's avatar
soniajs
Frequent Visitor
5 years ago
Solved

Subscription data - Revenue and Active Subscribers calculations

Hi,

 

I have a dataset like below. So, I want to calculate the Revenue generated for MTD,QTD,YTD and want to show it in different cards. I've shared the formula's I'm using below. But I'm getting same Revenue numbers for MTD, QTD and YTD.

EmailNameSubscription Price (Monthly)Subscription Start DateSubscription End DateSubscription Status
[email protected]Abc803-Jan-202105-Jan-2021Cancelled
[email protected]Klen1222-Feb-2021 Active
[email protected]David822-Feb-202122-Mar-2021Cancelled
[email protected]Philip822-Mar-202122-Jul-2021Cancelled
[email protected]Kenn F618-Apr-2021 Active
[email protected]Ronald G7.522-Apr-2021 Active
[email protected]Elmo413-May-202113-Jun-2021Cancelled
[email protected]Sonia22.530-May-2021 Active
[email protected]Katie631-May-2021 Active
[email protected]Diana1030-Jun-2021 Active
[email protected]Lawrence530-Jun-202130-Jul-2021Cancelled
[email protected]Valentine1010-Jul-2021 Active
[email protected]Scott2712-Jul-2021 Active
[email protected]Carine21614-Jul-2021 Active
[email protected]Jason5215-Jul-2021 Active
[email protected]Allwyn626-Jul-2021 Active
[email protected]Rex2627-Jul-2021 Active
[email protected]Elizabeth829-Jul-2021 Active
[email protected]Sierra1102-Aug-2021 Active
[email protected]Sharon13.503-Aug-2021 Active

 

Revenue = CALCULATE(SUM(Sheet1[Subscription Price (Monthly)]),FILTER(ALL(Sheet1),(Sheet1[Subscription Start Date]< Max('Date'[Date]) && Sheet1[Subscription End Date] >= Max('Date'[Date])) || Sheet1[Subscription Start Date] < Max ( 'Date'[Date] ) && ISBLANK ( Sheet1[Subscription End Date])))
 
Revenue MTD = CALCULATE([Revenue],DATESBETWEEN('Date'[Date],STARTOFMONTH('Date'[Date]),TODAY()))
Revenue QTD = CALCULATE([Revenue],DATESBETWEEN('Date'[Date],STARTOFQUARTER('Date'[Date]),TODAY()))
Revenue YTD = CALCULATE([Revenue],DATESBETWEEN('Date'[Date],STARTOFYEAR('Date'[Date]),TODAY()))
 
Thanks,
Sonia

 

  • Hi  soniajs ,

     

    Create 3 measures as below:

     

    MTD =
    VAR _tab =
        CALCULATETABLE (
            VALUES ( 'Date'[Date] ),
            FILTER (
                ALL ( 'Date' ),
                'Date'[Month] = SELECTEDVALUE ( 'Date'[Month] )
                    && YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) )
            )
        )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Subscription Price (Monthly)] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Subscription Start Date] <= MAXX ( _tab, [Date] )
                    && (
                        'Table'[Subscription End Date] >= MINX ( _tab, [Date] )
                            || 'Table'[Subscription End Date] = BLANK ()
                    )
                    && 'Table'[Email] = MAX ( 'Table'[Email] )
            )
        )
    
    QTD =
    VAR _tab =
        CALCULATETABLE (
            VALUES ( 'Date'[Date] ),
            FILTER (
                ALL ( 'Date' ),
                'Date'[Quarter] = SELECTEDVALUE ( 'Date'[Quarter] )
                    && YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) )
            )
        )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Subscription Price (Monthly)] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Subscription Start Date] <= MAXX ( _tab, [Date] )
                    && (
                        'Table'[Subscription End Date] >= MINX ( _tab, [Date] )
                            || 'Table'[Subscription End Date] = BLANK ()
                    )
                    && 'Table'[Email] = MAX ( 'Table'[Email] )
            )
        )
    
    YTD =
    VAR _tab =
        CALCULATETABLE (
            VALUES ( 'Date'[Date] ),
            FILTER ( ALL ( 'Date' ), YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) ) )
        )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Subscription Price (Monthly)] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Subscription Start Date] <= MAXX ( _tab, [Date] )
                    && (
                        'Table'[Subscription End Date] >= MINX ( _tab, [Date] )
                            || 'Table'[Subscription End Date] = BLANK ()
                    )
                    && 'Table'[Email] = MAX ( 'Table'[Email] )
            )
        )
    

     

    And you will see:

     

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my reply as a solution!

5 Replies

  • Your "Subscription price (monthly)" looks more like it is applied to the period from the start date of the subscription, not from the fist day of the month, right?

     

    With that - what is your expectation on the subscription cost for  [email protected] ?  Or anyone else who cancels their subscription before the end of the cycle?

    • soniajs's avatar
      soniajs
      Frequent Visitor

      Yes, it depends on the period from the start date of the subscription. For [email protected] , Jan month Revenue should be $8.

       

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

        Hi  soniajs ,

         

        Create 3 measures as below:

         

        MTD =
        VAR _tab =
            CALCULATETABLE (
                VALUES ( 'Date'[Date] ),
                FILTER (
                    ALL ( 'Date' ),
                    'Date'[Month] = SELECTEDVALUE ( 'Date'[Month] )
                        && YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) )
                )
            )
        RETURN
            CALCULATE (
                SUM ( 'Table'[Subscription Price (Monthly)] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Subscription Start Date] <= MAXX ( _tab, [Date] )
                        && (
                            'Table'[Subscription End Date] >= MINX ( _tab, [Date] )
                                || 'Table'[Subscription End Date] = BLANK ()
                        )
                        && 'Table'[Email] = MAX ( 'Table'[Email] )
                )
            )
        
        QTD =
        VAR _tab =
            CALCULATETABLE (
                VALUES ( 'Date'[Date] ),
                FILTER (
                    ALL ( 'Date' ),
                    'Date'[Quarter] = SELECTEDVALUE ( 'Date'[Quarter] )
                        && YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) )
                )
            )
        RETURN
            CALCULATE (
                SUM ( 'Table'[Subscription Price (Monthly)] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Subscription Start Date] <= MAXX ( _tab, [Date] )
                        && (
                            'Table'[Subscription End Date] >= MINX ( _tab, [Date] )
                                || 'Table'[Subscription End Date] = BLANK ()
                        )
                        && 'Table'[Email] = MAX ( 'Table'[Email] )
                )
            )
        
        YTD =
        VAR _tab =
            CALCULATETABLE (
                VALUES ( 'Date'[Date] ),
                FILTER ( ALL ( 'Date' ), YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) ) )
            )
        RETURN
            CALCULATE (
                SUM ( 'Table'[Subscription Price (Monthly)] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Subscription Start Date] <= MAXX ( _tab, [Date] )
                        && (
                            'Table'[Subscription End Date] >= MINX ( _tab, [Date] )
                                || 'Table'[Subscription End Date] = BLANK ()
                        )
                        && 'Table'[Email] = MAX ( 'Table'[Email] )
                )
            )
        

         

        And you will see:

         

        For the related .pbix file,pls see attached.

         

        Best Regards,
        Kelly

        Did I answer your question? Mark my reply as a solution!