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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ebeauchamp
Helper I
Helper I

Count Leavers based on conditions (revenue this period and previous period)

Hi everyone,

 

I am trying to do a distinct count of leaving customers that match two criterias: had a revenue > 0 in the previous period, and is at 0 in this period. Can't get the right syntax so thanks for your help!

For other needs, the time periods work well with the date slicer on the page, and are measured like this:

This Period Revenue = SUM(Transactions[DailyUsage$])

 

Previous Period Revenue = CALCULATE(SUM(Transactions[DailyUsage$])
,DATESBETWEEN(
Dates[Date],
[Start of Previous Period],
[End of Previous Period]),
ALL(Dates) )

 

This measure is also working well:
CountOrganizations = CALCULATE(DISTINCTCOUNT(Transactions[OrganizationUniqueName]))

 

It's when trying to add conditions to this count that I can't get it to work. Example tried from seeing other posts:
CountLeavers = CALCULATE(DISTINCTCOUNT(Transactions[OrganizationUniqueName]),FILTER(ALL(Transactions),[Previous Period Revenue]>0,[This Period Revenue]=0))

Any idea on how to make it work? Thanks

 

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @ebeauchamp 

Due to filters interfering with each other ,it maybe failed to get correct figure.

I think if  other measures work well, you'd better to use these  measures as variables in measure “CountLeavers”, similar to the following:

CountLeavers= 
var  _This_Period_Revenue = SUM(Transactions[DailyUsage$])
var  _Previous_Period_Revenue = CALCULATE(SUM(Transactions[DailyUsage$])
,DATESBETWEEN(
Dates[Date],
[Start of Previous Period],
[End of Previous Period]),
ALL(Dates) )
Return
CALCULATE(DISTINCTCOUNT(Transactions[OrganizationUniqueName]),FILTER(ALL(Transactions),_Previous_Period_Revenue>0,_This_Period_Revenue=0))

If it doesn't meet your requirement, kindly share your sample data and expected result if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
v-easonf-msft
Community Support
Community Support

Hi, @ebeauchamp 

Due to filters interfering with each other ,it maybe failed to get correct figure.

I think if  other measures work well, you'd better to use these  measures as variables in measure “CountLeavers”, similar to the following:

CountLeavers= 
var  _This_Period_Revenue = SUM(Transactions[DailyUsage$])
var  _Previous_Period_Revenue = CALCULATE(SUM(Transactions[DailyUsage$])
,DATESBETWEEN(
Dates[Date],
[Start of Previous Period],
[End of Previous Period]),
ALL(Dates) )
Return
CALCULATE(DISTINCTCOUNT(Transactions[OrganizationUniqueName]),FILTER(ALL(Transactions),_Previous_Period_Revenue>0,_This_Period_Revenue=0))

If it doesn't meet your requirement, kindly share your sample data and expected result if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
March Fabric Community Update

Fabric Community Update - March 2024

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

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.