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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors