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
Anonymous
Not applicable

Recuento Número de filas en función del estado

Hola a todos

Necesito ayuda con la siguiente pregunta:

Tengo los siguientes datos

Nombrestatus1status2
A10
A01
B00
B00
B10
C01
C00

Necesito escribir una consulta DAX donde debería contar tales filas cuyo estado1 - 1 y status2 nunca fue 1

En el ejemplo anterior, debemos contar como 1.

porque B es la única entrada para la que status1- 1 y status2 nunca llegó a ser 1.

No puedo crear una tabla ya que necesito llevar a cabo esta operación en un conjunto de datos en tiempo real.

Gracias

Vaibhav

6 REPLIES 6
v-alq-msft
Community Support
Community Support

Hola, @vmishra1

Según su descripción, creé datos para reproducir su escenario. El archivo pbix se adjunta al final.

Mesa:

e1.png

Puede crear una medida como se indica a continuación.

Count = 
var tab = 
ADDCOLUMNS(
    'Table',
    "Flag",
    var _name = [Name]
    var _sts1 = [status1]
    var _sts2 = [status2]
    return
    IF(
        [status1]=1&&
        COUNTROWS(
                FILTER(
                    ALL('Table'),
                    'Table'[Name]=_name&&
                    'Table'[status2]=1
                )
        )=BLANK()
        ,
        1,0
    )
)
return
COUNTROWS(
    FILTER(
        tab,
        [Flag]=1
    )
)

Resultado:

e2.png

Saludos

Allan

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

parry2k
Super User
Super User

@vmishra1 puede agregar la siguiente columna y luego sumar en esta columna para obtener el recuento

Col = 
VAR __totalRowsStatus2 = CALCULATE ( SUM ( 'status'[status2] ), ALLEXCEPT ( 'status', 'status'[Name] ) )
RETURN
IF ( 'status'[status1] = 1  && __totalRowsStatus2 = 0, 1 , 0 )

Me gustaría elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos enhttps://perytus.com, su ventanilla única para proyectos/formación/consulta relacionados con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k : Gracias por su mensaje.

Necesitamos contar la fila solo cuando status1 - 1 y status2 <> 1 en todas las entradas como filas.

@vmishra1 no está seguro, la solución que publiqué se basa en su publicación original, ¿lo probó? No estoy seguro de cuál es tu última respuesta.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k : lo siento, pero no tengo la opción de agregar una columna a la tabla de datos. ¿Se puede llevar a cabo en la mesa temporal?

Por favor, guíame ya que soy bastante nuevo en este mundo.

@vmishra1

tal vez probar esta medida

Measure = CALCULATE(COUNTROWS('Table (3)'),FILTER('Table (3)','Table (3)'[status1]=1&&'Table (3)'[status2]<>1))

Sin embargo, me pregunto por qué no contaste la primera fila. porque que A es 1 para el estado 1 y 0 para el estado 2 también.





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

Proud to be a Super User!




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.