Forum Discussion

Lodan's avatar
Lodan
Icon for Helper II rankHelper II
1 year ago
Solved

Measure count and median

Hello,   I have a math problem and I hope you can help please.   I have a data source of customers, revenue, when it started and when it stopped etc.  One customer could be in it multiple times. ...
  • DataNinja777's avatar
    1 year ago

    Hi Lodan ,

     

    The discrepancy you're seeing in the customer count and median MRR likely comes from how context is handled within your measures. The [MRR Revenue] measure involves multiple currency conversions and filters based on start and end dates. However, in your Client Count and Median MRR measures, you're summarizing the Combined table directly, which might not align with the way [MRR Revenue] is computed in the visual. To resolve this, you can explicitly calculate [MRR Revenue] for each customer, applying the same logic and filters, and then derive both the count and median from this list of customers with actual MRR values. Here's how you can rewrite the measures:

    Current Customer Count = 
    VAR MaxDate = CALCULATE( MAX( 'Dates2'[Date] ) )
    VAR T1 =
        ADDCOLUMNS (
            VALUES( Combined[Customer] ),
            "CustomerMRR", 
                CALCULATE(
                    [MRR Revenue],
                    Combined[End Date] > MaxDate,
                    Combined[Start Date] <= MaxDate,
                    Combined[PON or Not] IN { "PON", "Excluded" }
                )
        )
    RETURN
        COUNTROWS(
            FILTER( T1, [CustomerMRR] > 0 )
        )
    
    Median MRR = 
    VAR MaxDate = CALCULATE( MAX( 'Dates2'[Date] ) )
    VAR T1 =
        ADDCOLUMNS (
            VALUES( Combined[Customer] ),
            "CustomerMRR", 
                CALCULATE(
                    [MRR Revenue],
                    Combined[End Date] > MaxDate,
                    Combined[Start Date] <= MaxDate,
                    Combined[PON or Not] IN { "PON", "Excluded" }
                )
        )
    RETURN
        MEDIANX (
            FILTER( T1, [CustomerMRR] > 0 ),
            [CustomerMRR]
        )
    

    These versions ensure that only customers contributing non-zero MRR values at the selected reporting date are included in the count and median calculations, matching exactly what’s displayed in your visual.

     

    Best regards,