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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Calculate attrition with distinct clients ids

Hello Experts,

 

I have a report table with :
- Multiple Report periods with same values (one by reseller active contract over period): 01/01/2021,01/12/2021,01/11/2021 ....
- Those resellers can have multiple contracts with the same reference for the same period.

I must retrieve the distinct lost contracts from previous periods ( month -1, month -2 ...)
I have tried comparing two results with except but i don't know why this is not working as it doesn't return correcly my reseller ref.

Attrition M = 
var _Q = SELECTEDVALUE(Revenue[Period])
var _Q_1 = DATEADD(Revenue[Period],-1,MONTH)
var _Resellers = CALCULATETABLE(DISTINCT(Revenue[Reseller Ref]),
                    FILTER (ALL(Revenue[Period]),
                    Revenue[Period] = _Q))
var _Old_resellers = CALCULATETABLE(DISTINCT(Revenue[Reseller Ref]),
                     FILTER (ALL(Revenue[Period]),
                      Revenue[Period] = _Q_1))
RETURN
COUNTROWS(
    EXCEPT(_Old_resellers,_Resellers)
)

I give you a sample with my queries in attachment:
powerbi_sample 


Regards.

2 REPLIES 2
Anonymous
Not applicable

Thank you for your reply @amitchandak  I am really lost !
In fact it seems the same problem than my other request:

 

 

MTD = 
var _Q = SELECTEDVALUE(Revenue[Period])
var _Resellers = CALCULATETABLE(DISTINCT(Revenue[Reseller Ref]),
                    FILTER (ALL(Revenue[Period]),
                    Revenue[Period] = _Q))
RETURN
COUNTROWS(_Resellers)

LMTD = 
var _Q_1 = DATEADD(Revenue[Period],-1,MONTH)
var _Old_resellers = CALCULATETABLE(DISTINCT(Revenue[Reseller Ref]),
                     FILTER (ALL(Revenue[Period]),
                     Revenue[Period] = _Q_1))
RETURN
COUNTROWS(_Old_resellers)

Lost MTD = SUMX(VALUES(Revenue[Reseller Ref]),if(ISBLANK([MTD]) && not(ISBLANK([LMTD])) , 1,BLANK()))
New MTD = SUMX(VALUES(Revenue[Reseller Ref]),if(ISBLANK([LMTD]) && not(ISBLANK([MTD])) , 1,BLANK()))

 

 

I retrieve 0 values for LOST MTD. It seems related to SELECTEDVALUE segment:
Capture3.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Which retrieve multiple values from my report:
Capture2.PNG

amitchandak
Super User
Super User

@Anonymous , refer if this approach of using isblank can help

 

Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/ba-p/1361529
Customer Retention Part 2: Period over Period Retention :https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.