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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Syndicate_Admin
Administrator
Administrator

Promedio de un campo basado en la condición de otra columna

Hola, necesito ayuda en DAX mientras calculo el promedio de Ecode. La condición sería si el recuento del código S coincide con el recuento distinto del código E, excluirá al calcular el promedio. Si el recuento del código S no coincide con el recuento distinto del código E, entonces tomará un recuento distinto del código E y, en base a eso, necesito calcular el promedio. ¿Cuál debería ser el enfoque? Cualquier ayuda sería realmente apreciada.Shown here how it would be calculatedShown here how it would be calculatedAquí se muestra cómo se calcularía

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

¿Es esto lo que estás buscando?

Control = VAR _DisE =DISTINCTCOUNT('Table'[E Code])
          VAR _CounS = COUNT('Table'[S Code]) 
          VAR _Cont = IF(_DisE<> _CounS,_DisE)
RETURN
_Cont

Flag = IF([Control],1,0)


Final = var _t1 = SUMX(VALUES('Table'[S Code]),[Control])
        VAR _t2 = SUMX(VALUES('Table'[S Code]),[Flag])
RETURN
_t1/_t2

Archivo PBIX de muestra adjunto
https://dropmefiles.com/EJ14P

Screen Capture #265.png

Hola, esta es la solución exacta que estaba buscando. Muchas gracias.

Syndicate_Admin
Administrator
Administrator

Este es un enfoque para resolver el problema en DAX:

  1. Create a calculated column that checks if the count of S code matches the distinct count of E code.

    Coincidencia = CONTAR(S_Code) = DISTINCTCOUNT(E_Code)

    1. Create another calculated column to get the count of distinct E code based on the previous calculated column.
      E_Code_Count = IF([Match]=TRUE(),0,DISTINCTCOUNT(E_Code))

      1. Create a measure to calculate the average of E code based on the previous calculated column.

        Avg_E_Code = AVERAGEX(FILTER(ALL(Table),[E_Code_Count]>0),[E_Code])

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors
Top Kudoed Authors