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 equipo,
Tengo un requisito para calcular la suma (ventas) para el período pasado un mes actual-próximo mes
Por ejemplo: Tengo filtro Fecha que tiene todas las fechas de 2017 - fecha actual
cuando el usuario selecciona 10-sep-2020 tiene que obtener las ventas desde el 1-Aug-2020 hasta el 31-Oct-2020
También necesito mostrar al usuario el período "1-Aug-2020 hasta 31-Oct-2020" en el mismo objeto visual de la tabla.
Por favor, ayúdame ¿cómo puedo calcular esto?
Solved! Go to Solution.
Hola @LP280388 ,
Por favor, compruebe:
period =
VAR StartDate =
IF (
SELECTEDVALUE ( 'Dates'[Date] ) = BLANK (),
FORMAT (
EOMONTH ( MINX ( ALL ( 'Table' ), 'Table'[Date] ), -1 ) + 1,
"d-MMM-YYYY"
),
FORMAT ( EOMONTH ( SELECTEDVALUE ( Dates[Date] ), -2 ) + 1, "d-MMM-YYYY" )
)
VAR EndDate =
IF (
SELECTEDVALUE ( 'Dates'[Date] ) = BLANK (),
FORMAT ( EOMONTH ( MAXX ( ALL ( 'Table' ), 'Table'[Date] ), 0 ), "d-MMM-YYYY" ),
FORMAT ( EOMONTH ( SELECTEDVALUE ( Dates[Date] ), 1 ), "d-MMM-YYYY" )
)
RETURN
StartDate & " till " & EndDate
Sum =
VAR StartDate =
EOMONTH ( SELECTEDVALUE ( Dates[Date] ), -2 ) + 1
VAR EndDate =
EOMONTH ( SELECTEDVALUE ( Dates[Date] ), 1 )
RETURN
IF (
SELECTEDVALUE ( Dates[Date] ) = BLANK (),
SUM ( 'Table'[Value] ),
SUMX (
FILTER (
ALL ( 'Table' ),
'Table'[Date] >= StartDate
&& 'Table'[Date] <= EndDate
),
'Table'[Value]
)
)
Saludos
Icey
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Hola @LP280388 ,
Por favor, compruebe:
period =
VAR StartDate =
IF (
SELECTEDVALUE ( 'Dates'[Date] ) = BLANK (),
FORMAT (
EOMONTH ( MINX ( ALL ( 'Table' ), 'Table'[Date] ), -1 ) + 1,
"d-MMM-YYYY"
),
FORMAT ( EOMONTH ( SELECTEDVALUE ( Dates[Date] ), -2 ) + 1, "d-MMM-YYYY" )
)
VAR EndDate =
IF (
SELECTEDVALUE ( 'Dates'[Date] ) = BLANK (),
FORMAT ( EOMONTH ( MAXX ( ALL ( 'Table' ), 'Table'[Date] ), 0 ), "d-MMM-YYYY" ),
FORMAT ( EOMONTH ( SELECTEDVALUE ( Dates[Date] ), 1 ), "d-MMM-YYYY" )
)
RETURN
StartDate & " till " & EndDate
Sum =
VAR StartDate =
EOMONTH ( SELECTEDVALUE ( Dates[Date] ), -2 ) + 1
VAR EndDate =
EOMONTH ( SELECTEDVALUE ( Dates[Date] ), 1 )
RETURN
IF (
SELECTEDVALUE ( Dates[Date] ) = BLANK (),
SUM ( 'Table'[Value] ),
SUMX (
FILTER (
ALL ( 'Table' ),
'Table'[Date] >= StartDate
&& 'Table'[Date] <= EndDate
),
'Table'[Value]
)
)
Saludos
Icey
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Hola @LP280388
Dada esta estructura de datos y tabla de fechas:
Puede crear una medida:
Sum =
CALCULATE(Sum(Tbl[Value]),
FILTER(ALL('Date'[Date]),
'Date'[Date] >= DATE(YEAR(MAX('Date'[Date])), MONTH(MAX('Date'[Date]))-1,1)
&& 'Date'[Date] <= DATE(YEAR(MAX('Date'[Date])), MONTH(MAX('Date'[Date]))+1,30)
)
)
En el informe, en el objeto visual de segmentación de datos, agregue Fecha desde la tabla Fecha y, además, Tarjeta, que le mostrará el resultado de la medida.
Resultado de la muestra:
_______________
Si ayudé, por favor acepte la solución y dar felicitaciones! 😀
@lkalawski Gracias por la respuesta.
Yo también tengo el mismo resultado de su medida.
lo que necesito es, cuando selecciono cualquier fecha en Sep, debe dar el mismo resultado calculado del 1 de agosto al 31 de octubre independientemente de la fecha que seleccione en Sep.
Hola @LP280388
¿Puede compartir su muestra de datos y relaciones entre tablas?
Creo que ese problema es con la relación, pero quiero comprobarlo.
_______________
Si ayudé, por favor acepte la solución y dar felicitaciones! 😀
No puedo compartir el archivo ya que no puedo crear datos ficticios.
la relación entre las tablas Fecha y ventas es de 1 a muchas. Así es como modifiqué la medida.
@LP280388 , Con una tabla de fechas, pruebe una medida como
CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],Startofmonth(dateadd(Sales[Sales Date],-1,month)),3,MONTH))
Eso acumulará los datos en un mes: para eso se refiere :https://www.youtube.com/watch?v=duMSovyosXE
@amitchandak Gracias Amit,
Intenté lo de abajo. Su funcionamiento, pero el problema es cuando selecciono cualquier fecha entre 1-sep-2020 a 20-Sep-2020, esto debe dar el mismo valor que se calcula para el período 1-aug-2020 a 31-Oct-2020. Pero no es así.
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 |