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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jmcph
Helper III
Helper III

Promedio por categoría

Hola

Estoy haciendo algunos cálculos de promediación, y mis cálculos parecen estar bastante apagados. Sólo quiero pedir que se corrija por qué mi medida no parece funcionar. Mis datos son los siguientes:

En mi tabla Masterlist:
Valor de fecha del atributo del prestatario

Préstamo ABC 1/1/2019 1000

Colección ABC 1/5/2019 300
Préstamo ABC 2/5/2019 3000

Mis medidas fueron las siguientes:

AverageLoan ?
Fue
SumLoan - Calcular (
Sum( Masterlist[Value] ), Masterlist[Atributo] - "Importe del préstamo")

devolución
AVERAGEX (
All( 'Calendario'[Fecha]) , SumLoan )

Lo que estoy después es calcular para el promedio por prestatario. Mi cortador incluye Meses y Años.
Cuando entré en la medida antes mencionada me muestra un resultado de 4.000 (para el año 2019) que espero devolver un valor de 2.000. Por favor, ilumíneme sobre lo que hice mal.

¡Muchas gracias por cualquier ayuda que puedas proporcionar! ¡Salud!

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Hola, @jmcph , la causa del problema radica en el aprovechamiento de una variable dentro de la iteración.

De hecho, variable en DAX NO siempre es variable, consulte:

https://radacad.com/caution-when-using-variables-in-dax-and-power-bi

In DAX, variables are calculated within the scope in which they are written, and then the result of them is stored and used in the rest of the expression.

Para ser más precisos con su problema, cuando AVERAGEX itera All( 'Calendar'[Date]) (siendo "1/1", "1/5", "2/5"), SumLoan se utiliza 3 veces con el mismo valor, que se calcula en iteración "1/1". Además, SumLoan se define en el ámbito más externo de la medida, sólo el contexto de filtro inicial en lugar de "1/1", como segmentación de datos, fila / columna de visualización, etc., se utiliza en el cálculo.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Hola, @jmcph , la causa del problema radica en el aprovechamiento de una variable dentro de la iteración.

De hecho, variable en DAX NO siempre es variable, consulte:

https://radacad.com/caution-when-using-variables-in-dax-and-power-bi

In DAX, variables are calculated within the scope in which they are written, and then the result of them is stored and used in the rest of the expression.

Para ser más precisos con su problema, cuando AVERAGEX itera All( 'Calendar'[Date]) (siendo "1/1", "1/5", "2/5"), SumLoan se utiliza 3 veces con el mismo valor, que se calcula en iteración "1/1". Además, SumLoan se define en el ámbito más externo de la medida, sólo el contexto de filtro inicial en lugar de "1/1", como segmentación de datos, fila / columna de visualización, etc., se utiliza en el cálculo.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

vanessafvg
Super User
Super User

Creo que podrías estar componiendo demasiado

AverageLoan - CALCULATE(AVERAGE(MasterList[Value]), MasterList[Atributo] - "Préstamo")




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Sí. Gracias por la entrada. Creo que voy a hacer el cálculo promedio normal primero, luego hacer otra medida filtrando las fechas para hacerlo más simple. ¡Te lo agradezco!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors