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
bizintelguy604
Frequent Visitor

Medir con varias sentencias if y filtros

Estoy tratando de crear una nueva medida con varias instrucciones if sin embargo estoy recibiendo un error. ¿Algún consejo?

Si ListingStatus á "Inactive" entonces calcular una expresión determinada usando Calculate(sumx( con filtros.

Si ListingStatus - "Active" entonces calcule el mismo express con filtros sumx ligeramente diferentes.

Aquí está la medida:
*************************************************
Tasa de pedido promedio (ponderado) :
SI (
Listado[ListingStatus] á "Inactivo",
DIVIDE (
CALCULAR (
SUMX ( 'Listing', Listing[NetAskRate] * Listing[ListingAvailableSF] ),
Listado[NetAskRate] > 0,
DATESINPERIOD (
ListingRemovalDate[ListingRemovalDate_DateOnly],
HOY (),
-12,
Mes
)
),
CALCULAR (
SUM ( [ListingAvailableSF] ),
Listado[NetAskRate] > 0,
DATESINPERIOD (
ListingRemovalDate[ListingRemovalDate_DateOnly],
HOY (),
-12,
Mes
)
)
),
SI (
Listado[ListingStatus] á "Activo",
DIVIDE (
CALCULAR (
SUMX ( 'Listing', Listing[NetAskRate] * Listing[ListingAvailableSF] ),
Listado[NetAskRate] > 0
),
CALCULATE ( SUM ( [ListingAvailableSF] ), Listado[NetAskRate] > 0 )
)
)
)


**************************************************
Aquí está la advertencia de error:

Advertencia 1 Medida 'Listado'[Tasa de pedido media (ponderada)] : El valor de la columna 'ListingStatus' en la tabla 'Listing' no se puede determinar en el contexto actual. Compruebe que existen todas las columnas a las que se hace referencia en la expresión de cálculo y que no hay dependencias circulares. Esto también puede ocurrir cuando la fórmula de una medida hace referencia directamente a una columna sin realizar ninguna agregación (como suma, promedio o recuento) en esa columna. La columna no tiene un solo valor; tiene muchos valores, uno para cada fila de la tabla y no se ha especificado ninguna fila. P:'MarketingTabularModel'MarketingTabularModel'Model.bim 0 0 MarketingTabularModel

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hola @bizintelguy604 ,

el primer argumento de la if-statement no es válido:

Tasa de pedido promedio (ponderado) :
SI (
Listado[ListingStatus] á "Inactivo",

esto hace referencia a una columna completa, pero necesita un único valor (escalar) en su lugar.
Esto podría lograrse mediante una función de agregación, como MIN o MAX:

Tasa de pedido promedio (ponderado) :
SI (
MAX ( Listing[ListingStatus] ) - "Inactivo",

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@bizintelguy604 , Probar como

Avg Asking Rate (Weighted) :=
IF (
      max(Listing[ListingStatus]) = "Inactive",
      DIVIDE (
             CALCULATE (
                   SUMX ( 'Listing', Listing[NetAskRate] * Listing[ListingAvailableSF] ),
                   Listing[NetAskRate] > 0,
                   DATESINPERIOD (
                         ListingRemovalDate[ListingRemovalDate_DateOnly],
                         TODAY (),
                          -12,
                          MONTH
                    )
               ),
               CALCULATE (
                     SUM ( [ListingAvailableSF] ),
                     Listing[NetAskRate] > 0,
                     DATESINPERIOD (
                             ListingRemovalDate[ListingRemovalDate_DateOnly],
                             TODAY (),
                              -12,
                           MONTH
                )
         )
),
IF (
        max(Listing[ListingStatus]) = "Active",
        DIVIDE (
              CALCULATE (
                      SUMX ( 'Listing', Listing[NetAskRate] * Listing[ListingAvailableSF] ),
                      Listing[NetAskRate] > 0
               ),
               CALCULATE ( SUM ( [ListingAvailableSF] ), Listing[NetAskRate] > 0 )
          )
     )
)

Hola @amitchandak ,

preguntándose si usted vio otros defectos en la medida o acaba de escribir el código de medida completo con los cambios que sugerí?

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

@ImkeF, mi mala señorita. Gracias por apuntar.

ImkeF
Super User
Super User

Hola @bizintelguy604 ,

el primer argumento de la if-statement no es válido:

Tasa de pedido promedio (ponderado) :
SI (
Listado[ListingStatus] á "Inactivo",

esto hace referencia a una columna completa, pero necesita un único valor (escalar) en su lugar.
Esto podría lograrse mediante una función de agregación, como MIN o MAX:

Tasa de pedido promedio (ponderado) :
SI (
MAX ( Listing[ListingStatus] ) - "Inactivo",

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.