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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

¡Necesita ayuda con la medida! Clientes en curso marcados como perdidos.

Hola una vez más,

¡He estado gastando demasiado tiempo en esto y comenzando a tener los ojos cruzados! Tan cerca pero tan lejos. Básicamente estoy tratando de encontrar clientes perdidos en función de las fechas de inicio y finalización.

Un cliente se pierde si:

> fecha de inicio es de más de 365 días a partir de la fecha de finalización OR;
> La última fecha de finalización no tiene fecha de inicio futura y ha superado la fecha actual de hoy().

Como puedes ver a continuación:
> Las primeras cinco filas del 18-dic-13 [Start_Date_c] al 18-dic-14 [End_Date__C] están "perdidas", lo cual es incorrecto.

> Las siguientes cinco filas del 18-dic-13 [Start_Date_c] al 18-dic-18 [End_Date__C] están en blanco y no están perdidas ya que hay una renovación [Start_Date_c] para el 18-dic-18.

Sin embargo, dado que [End_Date__C] se extiende hasta 2018, las primeras cinco filas no se pierden técnicamente después de que terminó el período [End_Date__C] 2014 porque el período 2018 todavía estaba activo.

awff_2-1647936490398.png

A continuación se muestra el DAX utilizado, que puede ser más compicado de lo que debería ser (o tal vez no lo suficiente):

Is Lost = //Customer is lost when no maintenance in the following 12 months 
var _prevSales = '_fact (Quote)'[AccountID]
var _prevEnd = '_fact (Quote)'[End_Date__c]
var _prevStart = '_fact (Quote)'[Start_Date__c]
var _nextStart = --next latest start date from current end date
CALCULATE(
    min('_fact (Quote)'[Start_Date__c]),
    FILTER(
        ALL('_fact (Quote)'),
        '_fact (Quote)'[QuoteStatus (invoiceRequested)] = "Invoiced" &&
        '_fact (Quote)'[AccountID] = _prevSales &&
       '_fact (Quote)'[start_Date__c] >= _prevEnd))
VAR _nextEnd = --next latest end date from current end date
CALCULATE(
    MIN('_fact (Quote)'[end_Date__c]),
    FILTER(
        ALL('_fact (Quote)'),
        '_fact (Quote)'[QuoteStatus (invoiceRequested)] = "Invoiced" &&
        '_fact (Quote)'[AccountID] = _prevSales &&
       '_fact (Quote)'[end_Date__c] > _prevEnd))
VAR _FinalEnd = --look for the very latest end date for the account
minx(
    filter(
        '_fact (Quote)', 
        '_fact (Quote)'[AccountID] = _prevSales &&
        '_fact (Quote)'[End_Date__c] > _prevEnd &&
        '_fact (Quote)'[QuoteStatus (invoiceRequested)] = "Invoiced" ),
    '_fact (Quote)'[AccountID])
return
 SWITCH(
    TRUE(),
--ignore if start or end date is blank (bad data input):
    Or(isblank('_fact (Quote)'[Start_Date__c]), isblank( '_fact (Quote)'[End_Date__c])), blank(),
-- if next start date is 365 days since the previous end date AND (for increased seats) the next end date is more than 365 since the previous end date then LOST:
    _nextStart > '_fact (Quote)'[End_Date__c] && _nextEnd > '_fact (Quote)'[End_Date__c] + 365, "lost",
--if final end date is past current (today) date then LOST:
    '_fact (Quote)'[End_Date__c] < today() && isblank(_FinalEnd) , "lost",
    blank())


¡Su ayuda es muy apreciada!
Andrew

1 ACCEPTED SOLUTION

Después de jugar con numerosas variaciones, he logrado resolver esto usando el siguiente DAX, que de hecho era mucho más simple:

Islost2 = //Customer is lost when no maintenance in the following 12 months 
var _prevSales = '_fact (Quote)'[AccountID]
var _prevEnd = '_fact (Quote)'[End_Date__c]
var _prevStart = '_fact (Quote)'[Start_Date__c]
var _nextStart = --return next start date where current end date is older then the previous end date
CALCULATE(
    min('_fact (Quote)'[Start_Date__c]),
    FILTER(
        ALL('_fact (Quote)'),
        '_fact (Quote)'[QuoteStatus (invoiceRequested)] = "Invoiced" &&
        '_fact (Quote)'[AccountID] = _prevSales &&
       '_fact (Quote)'[end_Date__c] > _prevEnd))
VAR _FinalEnd = --look for the very latest end date for the account
minx(
    filter(
        '_fact (Quote)', 
        '_fact (Quote)'[AccountID] = _prevSales &&
        '_fact (Quote)'[End_Date__c] > _prevEnd &&
        '_fact (Quote)'[QuoteStatus (invoiceRequested)] = "Invoiced" ),
    '_fact (Quote)'[AccountID])
return
 SWITCH(
    TRUE(),
// Ignore if start or end date is blank (bad data input):
    Or(isblank('_fact (Quote)'[Start_Date__c]), isblank( '_fact (Quote)'[End_Date__c])), blank(),
//Next start date is more than 30 days since last end date
    '_fact (Quote)'[end_Date__c] < _nextStart - 30, "lost",
// if final end date is past current (today) date then LOST:
    '_fact (Quote)'[End_Date__c] < today() && isblank(_FinalEnd) , "lost",
    blank())

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

@awff , Según su lógica, la fecha de inicio es de más de 365 días a partir de la fecha de finalización OR;

Lost es correcto ya que la próxima fecha de inicio es después de 4 años

Si esto no ayuda
¿Puede compartir datos de muestra y salida de muestra en formato de tabla?

Parece que no puedo encontrar una manera de adjuntar una muestra en este foro, pero aquí hay un enlace de Dropbox que lo dirigirá al archivo PBI de muestra:
https://www.dropbox.com/s/q0cqhtaphe3v20g/LostCustomerSample.pbix?dl=0

Correcto, pero en este ejemplo en particular siguen siendo un cliente activo ya que la próxima fecha de finalización se extiende más allá del anterior 2014.

Se requeriría una excepción de algún tipo en la línea de, no perdida si la fecha de inicio está dentro de un término activo y la fecha de finalización es más allá de la fecha de finalización menor anterior. Esencialmente, dado que la siguiente fecha de inicio estaba dentro de la fecha de inicio y finalización anterior, se anula si eso tiene sentido.

awff_1-1647939820908.png

Después de jugar con numerosas variaciones, he logrado resolver esto usando el siguiente DAX, que de hecho era mucho más simple:

Islost2 = //Customer is lost when no maintenance in the following 12 months 
var _prevSales = '_fact (Quote)'[AccountID]
var _prevEnd = '_fact (Quote)'[End_Date__c]
var _prevStart = '_fact (Quote)'[Start_Date__c]
var _nextStart = --return next start date where current end date is older then the previous end date
CALCULATE(
    min('_fact (Quote)'[Start_Date__c]),
    FILTER(
        ALL('_fact (Quote)'),
        '_fact (Quote)'[QuoteStatus (invoiceRequested)] = "Invoiced" &&
        '_fact (Quote)'[AccountID] = _prevSales &&
       '_fact (Quote)'[end_Date__c] > _prevEnd))
VAR _FinalEnd = --look for the very latest end date for the account
minx(
    filter(
        '_fact (Quote)', 
        '_fact (Quote)'[AccountID] = _prevSales &&
        '_fact (Quote)'[End_Date__c] > _prevEnd &&
        '_fact (Quote)'[QuoteStatus (invoiceRequested)] = "Invoiced" ),
    '_fact (Quote)'[AccountID])
return
 SWITCH(
    TRUE(),
// Ignore if start or end date is blank (bad data input):
    Or(isblank('_fact (Quote)'[Start_Date__c]), isblank( '_fact (Quote)'[End_Date__c])), blank(),
//Next start date is more than 30 days since last end date
    '_fact (Quote)'[end_Date__c] < _nextStart - 30, "lost",
// if final end date is past current (today) date then LOST:
    '_fact (Quote)'[End_Date__c] < today() && isblank(_FinalEnd) , "lost",
    blank())

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.