Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Bian
Helper II
Helper II

Count customers per Business Unit in a Subscription based model

Trying to solve a measure for a subscription based business.

The measure should calculate number of customers per month.

I work with a dataset that stores all the changes on the subscription. I can therefore have man rows per subscription.

The measure works fine except when a subscription is moved between Business units.

The customer then counts on both buinsess units instead of just the correct one.

The measure also counts correct when looking at the whole business.

 

I tried adding All(Business units) in both MaxPricedates and Results without effect.

 

Measure:

Number customers = 
VAR MaxDate =  
    MAX ( Date[Date] )
VAR FromDate = 
    ENDOFMONTH(Date[Date])
VAR EndDate = 
ENDOFMONTH('Subscriptions'[ActualDate])
VAR EndOfLifeDate =
    STARTOFMONTH(Date[Date])

VAR MaxPrisDates =
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ('Subscriptions','Subscriptions'[SubscriptionID]), 
            "@MaxBalanceDate", CALCULATE (Max('Subscriptions'[ActualDate]))
        ),
        Date[Date] <= MaxDate
        

    )
VAR MaxPrisDatesWithLineage =
    TREATAS ( MaxPrisDates, 'Subscriptions'[SubscriptionID], Date[Date]) 
VAR Result =
    CALCULATE( 
        DISTINCTCOUNT( 'Subscriptions'[AccountID]),
        MaxPrisDatesWithLineage,
        'Subscriptions'[Start date] <= FromDate, 
        'Subscriptions'[End date] >= EndOfLifeDate, 
        'Subscriptions'[Status] <> "Other",
        'Subscriptions'[Status] <> "Stopped"
        
        )
RETURN
   Result
Bian_0-1634101685023.png

 

Grateful for assistans
1 ACCEPTED SOLUTION

Solutions was actually what i already tried, that is to use All(Business Units). This time in the right place.

Number customers = 
VAR MaxDate =  
    MAX ( Date[Date] )
VAR FromDate = 
    ENDOFMONTH(Date[Date])
VAR EndDate = 
ENDOFMONTH('Subscriptions'[ActualDate])
VAR EndOfLifeDate =
    STARTOFMONTH(Date[Date])

VAR MaxPrisDates =
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ('Subscriptions','Subscriptions'[SubscriptionID]), 
            "@MaxBalanceDate", CALCULATE (Max('Subscriptions'[ActualDate]))
        ),
        All('Business Units'),
        Date[Date] <= MaxDate
        

    )
VAR MaxPrisDatesWithLineage =
    TREATAS ( MaxPrisDates, 'Subscriptions'[SubscriptionID], Date[Date]) 
VAR Result =
    CALCULATE( 
        DISTINCTCOUNT( 'Subscriptions'[AccountID]),
        MaxPrisDatesWithLineage,
        'Subscriptions'[Start date] <= FromDate, 
        'Subscriptions'[End date] >= EndOfLifeDate, 
        'Subscriptions'[Status] <> "Other",
        'Subscriptions'[Status] <> "Stopped"
        
        )
RETURN
   Result

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Bian ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Solutions was actually what i already tried, that is to use All(Business Units). This time in the right place.

Number customers = 
VAR MaxDate =  
    MAX ( Date[Date] )
VAR FromDate = 
    ENDOFMONTH(Date[Date])
VAR EndDate = 
ENDOFMONTH('Subscriptions'[ActualDate])
VAR EndOfLifeDate =
    STARTOFMONTH(Date[Date])

VAR MaxPrisDates =
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ('Subscriptions','Subscriptions'[SubscriptionID]), 
            "@MaxBalanceDate", CALCULATE (Max('Subscriptions'[ActualDate]))
        ),
        All('Business Units'),
        Date[Date] <= MaxDate
        

    )
VAR MaxPrisDatesWithLineage =
    TREATAS ( MaxPrisDates, 'Subscriptions'[SubscriptionID], Date[Date]) 
VAR Result =
    CALCULATE( 
        DISTINCTCOUNT( 'Subscriptions'[AccountID]),
        MaxPrisDatesWithLineage,
        'Subscriptions'[Start date] <= FromDate, 
        'Subscriptions'[End date] >= EndOfLifeDate, 
        'Subscriptions'[Status] <> "Other",
        'Subscriptions'[Status] <> "Stopped"
        
        )
RETURN
   Result

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors