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.
Hola : tengo una matriz configurada con columnas para las ventas del mes actual, las ventas de YTD y mis ventas totales del año anterior. Esta matriz utiliza una segmentación de datos para que pueda seleccionar el mes/año actual.
Para obtener el total de ventas del año anterior y omitir la segmentación de datos, utilizo esta medida:
Solved! Go to Solution.
[Editar] He enmendado la medida para que ahora funcione. La lógica estaba bien incluso antes, pero utilicé CALCULATE en lugar de CALCULATETABLE. Aquí es donde estaba el problema. Escribo medidas sin modelos, así que no tengo la oportunidad de depurar. Sólo confío en mi experiencia y si escribo tarde en la noche.... bueno, ya estoy cansado y los errores se arrastran. ¡arrepentido!
[Sales w/o April, May June] =
var PrevYearMonths =
CALCULATETABLE(
DISTINCT( 'Date table'[Date] ),
PREVIOUSYEAR( 'Date table'[Date] ),
// If you don't have a column called
// Month Name in the dates table, use
// anything that will identify full
// months in each year. So the months' identifier
// must have the same values for the same month
// in each year. You'll have to adjust the values
// in the curly braces as well in such a case.
NOT 'Date table'[Month Name] IN {
"April", "May", "June"
},
ALL( 'Date table' )
)
var Result =
CALCULATE(
[Total Charge Amount], // the base measure
PrevYearMonths
)
return
Result
El código estaba bien. En una línea completamente diferente utilicé CALCULATE en lugar de CALCULATETABLE. De ahí el problema. Pero la medida hace exactamente lo que estaba buscando.
Vea esto: https://dax.do/Wty121eh8QDrH2/
[Editar] He enmendado la medida para que ahora funcione. La lógica estaba bien incluso antes, pero utilicé CALCULATE en lugar de CALCULATETABLE. Aquí es donde estaba el problema. Escribo medidas sin modelos, así que no tengo la oportunidad de depurar. Sólo confío en mi experiencia y si escribo tarde en la noche.... bueno, ya estoy cansado y los errores se arrastran. ¡arrepentido!
[Sales w/o April, May June] =
var PrevYearMonths =
CALCULATETABLE(
DISTINCT( 'Date table'[Date] ),
PREVIOUSYEAR( 'Date table'[Date] ),
// If you don't have a column called
// Month Name in the dates table, use
// anything that will identify full
// months in each year. So the months' identifier
// must have the same values for the same month
// in each year. You'll have to adjust the values
// in the curly braces as well in such a case.
NOT 'Date table'[Month Name] IN {
"April", "May", "June"
},
ALL( 'Date table' )
)
var Result =
CALCULATE(
[Total Charge Amount], // the base measure
PrevYearMonths
)
return
Result
Gracias por responder 🙂 Sin embargo, esto no funciona para mí. El error es " La sintaxis de 'NOT' es incorrecta.
Era fácil de enmendar... Simplemente NO ponga delante de la expresión, no delante de IN. Ustedes, chicos, deberían pensar un poco más 🙂
En realidad lo intenté anoche y tampoco funciona. Pasé varias horas probando cosas disfías con las ideas que me dio tu código, y revisé las funciones NO y IN y nada de lo que he intentado está funcionando. El error que normalmente recibo es "La expresión true/false no especifica una columna"
Lo siento, no te creo. Estoy casi 100% seguro de que el código es completamente funcional. He hecho esas cosas incontables veces en el pasado. ¿Tal vez deberías actualizar tu PBI? Voy a tratar de demostrar a usted que funciona correctamente usando http://dax.do. Estén atentos. Volveré.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |