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 chicos,
Estoy atascado y me gustaría pedir ayuda.
Entonces, ¿qué me gustaría hacer? Obtenga la suma de los últimos tres meses y muéstrela para los próximos meses. Es complicado porque me gustaría referirme a la suma de agosto, septiembre y octubre siempre (como estamos en noviembre).
Así que permítanme mostrarles 2 tablas con la fórmula "Valor 3 meses atrás" que se ve así:
¿Y qué me gustaría lograr? Permítanme mostrarlo exactamente en Excel.
He probado un montón de cosas y funciona perfectamente mientras toma 3 meses desde el momento en que nos referimos, así que este "Valor 3 meses atrás" está cambiando. Me gustaría que fuera constante a lo largo de los próximos dos años fiscales y se basaría en el mes en el que estamos actualmente.
Solved! Go to Solution.
Hola, @trebor2mng
Puede probar esto en mi archivo de ejemplo anterior:
Measure =
SUMX (
SUMMARIZE (
Table1,
[Date],
[Value],
[Index],
"threemonthback",
VAR a =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 1 ), [Value] )
VAR b =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 2 ), [Value] )
VAR c =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 3 ), [Value] )
VAR d =
( b + c + a ) / 3
var e =
MAXX(FILTER(ALL(Table1),[Date]=SELECTEDVALUE(Table1[Date])),[Value])
RETURN
IF ( SELECTEDVALUE ( Table1[Index] ) < 3, e, d )
),
[threemonthback]
)
Difference =
SUMX (
ADDCOLUMNS (
SUMMARIZE (
Table1,
[Date],
[Value],
[Index],
"threemonthback",
VAR a =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 1 ), [Value] )
VAR b =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 2 ), [Value] )
VAR c =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 3 ), [Value] )
VAR d =
( b + c + a ) / 3
var e =
MAXX(FILTER(ALL(Table1),[Date]=SELECTEDVALUE(Table1[Date])),[Value])
RETURN
IF ( SELECTEDVALUE ( Table1[Index] ) < 3, e, d )
),
"difference", [threemonthback] - [Value]
),
[difference]
)
Measure 2 =
SUMX (
SUMMARIZE (
Table1,
[Value],
[Index],
"threemonthback",
VAR a =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 1 ), [Value] )
VAR b =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 2 ), [Value] )
VAR c =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 3 ), [Value] )
return
( b + c + a ) / 3
),
[threemonthback]
)
Por cierto, desea calcular la suma de 8,9,10, pero definió 7,8,9 como un trimestre. ¿Has considerado esto?
Si no resuelve su problema, por favor no dude en preguntarme.
Saludos
Janey Guo
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Muchas gracias por su ayuda. Funciona según lo esperado.
P.S. Sí, lo he considerado 🙂
Hola
@v-janeyg-msft gracias por su respuesta. Aprecio, sin embargo, este no es el resultado que he esperado.
Esta lógica que puedo lograr mediante una fórmula de ese tipo:
CALCULATE( SUMX('Table',IF(DATEDIFF('Table'[Date],TODAY(),MONTH) <-3 && DATEDIFF('Table'[Date],TODAY(),MONTH) >-1, 'Table'[Value],0))).
Lo que me gustaría mostrar y lo veo complicado es no mover el valor de los últimos 3 meses.
Este es tu pbix:
y lo que exactamente me gustaría ver es:
Así que el valor de agosto es 67, septiembre 88 y octubre 77. Nos da un total de 232.
Para la tabla mensual me gustaría que se dividiera por 3 (77.33) y se distribuyería por toda la tabla:
77.33 para noviembre, diciembre de 2021 y así sucesivamente. Siempre consulte los últimos 3 meses y luego calcule una diferencia.
Para la tabla trimestral me gustaría referir siempre a 232 valor para Q2, Q3, Q4.
¡Gracias!
saludos
Tt
Hola, @trebor2mng
Puede probar esto en mi archivo de ejemplo anterior:
Measure =
SUMX (
SUMMARIZE (
Table1,
[Date],
[Value],
[Index],
"threemonthback",
VAR a =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 1 ), [Value] )
VAR b =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 2 ), [Value] )
VAR c =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 3 ), [Value] )
VAR d =
( b + c + a ) / 3
var e =
MAXX(FILTER(ALL(Table1),[Date]=SELECTEDVALUE(Table1[Date])),[Value])
RETURN
IF ( SELECTEDVALUE ( Table1[Index] ) < 3, e, d )
),
[threemonthback]
)
Difference =
SUMX (
ADDCOLUMNS (
SUMMARIZE (
Table1,
[Date],
[Value],
[Index],
"threemonthback",
VAR a =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 1 ), [Value] )
VAR b =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 2 ), [Value] )
VAR c =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 3 ), [Value] )
VAR d =
( b + c + a ) / 3
var e =
MAXX(FILTER(ALL(Table1),[Date]=SELECTEDVALUE(Table1[Date])),[Value])
RETURN
IF ( SELECTEDVALUE ( Table1[Index] ) < 3, e, d )
),
"difference", [threemonthback] - [Value]
),
[difference]
)
Measure 2 =
SUMX (
SUMMARIZE (
Table1,
[Value],
[Index],
"threemonthback",
VAR a =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 1 ), [Value] )
VAR b =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 2 ), [Value] )
VAR c =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = 3 ), [Value] )
return
( b + c + a ) / 3
),
[threemonthback]
)
Por cierto, desea calcular la suma de 8,9,10, pero definió 7,8,9 como un trimestre. ¿Has considerado esto?
Si no resuelve su problema, por favor no dude en preguntarme.
Saludos
Janey Guo
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Hola, @trebor2mng
Es un placer responder por ti.
De acuerdo con su descripción, creo que puede crear una columna de índice en pq primero, luego crear dos medidas para calcular los resultados deseados.
Así:
Value 3 months back =
SUMX (
SUMMARIZE (
Table1,
[Date],
[Value],
[Index],
"threemonthback",
VAR a =
MAXX (
FILTER ( ALL ( Table1 ), [Date] = SELECTEDVALUE ( Table1[Date] ) ),
[Index]
)
VAR aa =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = a ), [Value] )
VAR b =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = a - 1 ), [Value] )
VAR c =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = a - 2 ), [Value] )
VAR d =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = a - 3 ), [Value] )
VAR e = ( b + c + d ) / 3
RETURN
IF ( SELECTEDVALUE ( Table1[Index] ) < 3, aa, e )
),
[threemonthback]
)
Difference =
SUMX (
ADDCOLUMNS (
SUMMARIZE (
Table1,
[Date],
[Value],
[Index],
"threemonthback",
VAR a =
MAXX (
FILTER ( ALL ( Table1 ), [Date] = SELECTEDVALUE ( Table1[Date] ) ),
[Index]
)
VAR aa =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = a ), [Value] )
VAR b =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = a - 1 ), [Value] )
VAR c =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = a - 2 ), [Value] )
VAR d =
SUMX ( FILTER ( ALL ( Table1 ), [Index] = a - 3 ), [Value] )
VAR e = ( b + c + d ) / 3
RETURN
IF ( SELECTEDVALUE ( Table1[Index] ) < 3, aa, e )
),
"difference", [threemonthback] - [Value]
),
[difference]
)
Aquí está mi archivo .pbix de ejemplo. Espero que ayude.
Si no resuelve su problema, por favor no dude en preguntarme.
Saludos
Janey Guo
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
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 |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |