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
grechill
Helper I
Helper I

No es el problema habitual de cálculo de totales

Hola a todos,

Tengo un problema con conseguir los totales correctos.

Estoy tratando de hacer comparación mes a mes para definir si el cliente ha dejado de pagar el contrato o hemos ganado el cliente (tasa de rotación). Hay varios tipos de productos y me gustaría tratarlos por separado.

Valor del mes anterior:

Amount PM = CALCULATE([Amount],DATEADD('Calendar'[Date],-1,MONTH))

Fórmula intermedia para definir si se trata de un cliente nuevo o perdido y para sumar:

z_int_Lost Customer Flag = 
IF(
    AND(
        [Amount]<=0,[Amount PM]>0),
        1,0)
z_int_New Customer Flag = 
IF(
    AND(
        [Amount]>0,[Amount PM]=0),
        1,0) 

Aquí está mi solución de totales habituales, sin embargo, no funciona esta vez

Test 1 = 
IF(
    HASONEFILTER(Data[Customer]),
    [z_int_Lost Customer Flag],
    SUMX(VALUES(Data[Customer]),[z_int_Lost Customer Flag]))

También he probado 2 otras soluciones que se encuentran en línea, pero que no funcionan cualquiera de los.

Test 2 = 
VAR _total = SUMMARIZE(Data,Data[Customer],'Calendar'[Year Month],'Product'[Product Group],"Lost",[z_int_Lost Customer Flag])
RETURN
IF(
    HASONEFILTER(Data[Customer]),
    [z_int_Lost Customer Flag],
    SUMX(_total,[Lost]))
Test 3 = SUMX(SUMMARIZE(Data,Data[Customer],'Calendar'[Year Month],'Product'[Product Group],"Lost",[z_int_Lost Customer Flag]),[Lost])

Por último, he hecho una tabla separada con conectores de puente, como se describe en este post. Sin embargo, esta solución no es flexible y me gustaría evitarla.

Adjunto un PBIX de maqueta con el problema de totales replicados. Tiene idéntica estructura y medidas.

UPD: Se han añadido más datos al conjunto y a la opción propuesta.

¡Esperando tu ayuda!

Atentamente

Sergey

1 ACCEPTED SOLUTION

Ok, lo he descubierto.

He utilizado la solución propuesta por @richbenmintz y añadí un ajuste estándar para fijar subtotales y totales para año / trimestre / mes.

Cliente perdido ?
SI(
HASONEFILTER(dim_Customer[Cliente]),
[z_Lost Cliente],
SUMX(VALUES('Calendar'[Year Month]),[z_Lost Cliente]))

View solution in original post

3 REPLIES 3
richbenmintz
Solution Sage
Solution Sage

Hola @grechill,

Consulte el archivo adjunto, smaple.pbix

He creado una dimensión de cliente y luego he utilizado la siguiente medida

Lost Customers = CALCULATE(COUNTX('Customers', COUNTROWS('Customers')), filter('Customers', [Amount]<=0 && [Amount PM] > 0))

Espero que esto ayude,
Richard
¿He respondido a tu pregunta? ¡Marca mi puesto como una solución!
¿Mis respuestas ayudaron a llegar a una solución? Dale un kudos haciendo clic en Thumbs Up!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Ok, lo he descubierto.

He utilizado la solución propuesta por @richbenmintz y añadí un ajuste estándar para fijar subtotales y totales para año / trimestre / mes.

Cliente perdido ?
SI(
HASONEFILTER(dim_Customer[Cliente]),
[z_Lost Cliente],
SUMX(VALUES('Calendar'[Year Month]),[z_Lost Cliente]))

Hi @richbenmintz ,

 

Sorry, I was too quick with assessment. It doesn't work. It shows subtotals, but they are incorrect. And it doesn't show totals at all.

 

I have updated data set with some data to test it and added your solution.

 

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.