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
Syndicate_Admin
Administrator
Administrator

Ayuda de Inteligencia de Tiempo

Me refiero al artículo siguiente para calcular una tabla que se utilizará para la inteligencia de tiempo.
Phil Seamark en DAX

He podido recrear algunas de las opciones que necesitaba siguiendo el mismo patrón. Los que estoy teniendo problemas son: El mes pasado, la semana pasada, Esta semana. Cuando el último mes, por ejemplo, se selecciona, me gustaría que solo mostrara los meses del mes pasado. Actualmente la fórmula siguiente calculará todo el mes pasado y hasta la fecha actual.

Inteligencia de Tiempo (Time Intelligence)
VAR Hoy - Hoy ()
VAR ThisYear - Año (Hoy)
VAR ThisMonth - MES(Hoy)
VAR Este Día - DIA(Hoy)
devolución
SELECTCOLUMNS(
Unión
(
Los últimos 2 meses
ADDCOLUMNS(
GENERAR(
SELECTCOLUMNS('Last 2 Months',"Period",[Value]) ,
GENERATESERIES(
DATE(ThisYear , ThisMonth - 2 , 1) ,
Hoy
)
),"Fecha del eje",[Valor]),

Los últimos 3 meses
ADDCOLUMNS(
GENERAR(
SELECTCOLUMNS('Last 3 Months"',"Period",[Value]) ,
GENERATESERIES(
DATE(ThisYear , ThisMonth - 3 , 1) ,
Hoy
)
),"Fecha del eje",[Valor]),

Año actual
ADDCOLUMNS(
GENERAR(
SELECTCOLUMNS('Año actual',"Período",[Valor]) ,
GENERATESERIES(
DATE(ThisYear , 1 , 1) ,
Hoy
)
),"Fecha del eje",[Valor]),

Año anterior
ADDCOLUMNS(
GENERAR(
SELECTCOLUMNS('Año anterior',"Período",[Valor]) ,
GENERATESERIES(
FECHA(ThisYear-1 , 1 , 1) ,
FECHA (ThisYear,ThisMonth-12,ThisDay)
)
),
"Axis Date",DATE(YEAR([Value]),MONTH([Value])+12,DAY([Value])
)
),


El mes pasado
ADDCOLUMNS(
GENERAR(
SELECTCOLUMNS('Año anterior',"Período",[Valor]) ,
GENERATESERIES(
DATE(ThisYear , ThisMonth -1 , 1) ,
FECHA (ThisYear,ThisMonth-1,ThisDay)
)
),
"Axis Date",DATE(YEAR([Value]),MONTH([Value])+12,DAY([Value])
)
),

Los últimos 28 días
ADDCOLUMNS(
GENERAR(
SELECTCOLUMNS('Last 28 Days"',"Period",[Value]) ,
GENERATESERIES(
DATE(ThisYear , ThisMonth , ThisDay-28) ,
Hoy-1
)
),
"Fecha del eje",[Valor]
)
,

Totales YTD
GENERAR(
SELECTCOLUMNS('Totales YTD',"Período",[Valor]) ,
Var BaseTable (VAR BaseTable)
SELECTCOLUMNS(
GENERATESERIES(
DATE(ThisYear , 1 , 1) ,
Hoy
),"D1",[Valor]
)
devolución
SELECTCOLUMNS(
GENERAR(
BaseTable ,
FILTRO(
SELECTCOLUMNS(BaseTable,"D2",[D1]) ,[D2]<-EARLIER([D1]))
)
,"Fecha",[D2]
,"Fecha del eje",[D1]
)
)

) ,
"Fecha" , [Valor] ,
"Período" , [Período] ,
"Fecha del eje" , [Fecha del eje]
)
2 ACCEPTED SOLUTIONS
Syndicate_Admin
Administrator
Administrator

@Jmccoy realizar este cambio en la expresión DAX para la lógica de los últimos 2 y 3 meses

instead of TODAY change it to

EOMONTH(Today,-1)

View solution in original post

Syndicate_Admin
Administrator
Administrator

No @Jmccoy

¿Algo como esto?

//Last Month 
ADDCOLUMNS (
    GENERATE (
        SELECTCOLUMNS ( { "Last Month" }, "Period", [Value] ),
        GENERATESERIES (
            EDATE ( DATE ( ThisYear, ThisMonth, 1 ), -1 ),
            DATE ( ThisYear, ThisMonth, 1 ) - 1
        )
    ),
    "Axis Date", [Value] 
)

y similares para los demás

Por favor, marque la pregunta resuelta cuando haya terminado y considere dar un pulgar hacia arriba si las publicaciones son útiles.

Póngase en contacto conmigo de forma privada para obtener asistencia con cualquier necesidad de BI a gran escala, tutoría, etc.

Salud

SU18_powerbi_badge

View solution in original post

7 REPLIES 7
Syndicate_Admin
Administrator
Administrator

@Jmccoy

Debe mostrar cuál es el resultado esperado exacto. Prueba esto

            // Current week
            ADDCOLUMNS (
                GENERATE (
                    SELECTCOLUMNS ( { "Current week" }, "Period", [Value] ),
                    VAR weekStart_ = Today - (WEEKDAY(Today,2)-1)
                    RETURN GENERATESERIES ( weekStart_, weekStart_+6)
                ),
                "Axis Date", [Value]
            ),
            // Last week
            ADDCOLUMNS (
                GENERATE (
                    SELECTCOLUMNS ( { "Last week" }, "Period", [Value] ),
                    VAR weekStart_ = Today-7 - (WEEKDAY(Today-7,2)-1)
                    RETURN GENERATESERIES ( weekStart_, weekStart_+6)
                ),
                "Axis Date", [Value]
            )

Por favor, marque la pregunta resuelta cuando haya terminado y considere dar un pulgar hacia arriba si las publicaciones son útiles.

Póngase en contacto conmigo de forma privada para obtener asistencia con cualquier necesidad de BI a gran escala, tutoría, etc.

Salud

SU18_powerbi_badge

Muchas gracias, esto está funcionando exactamente como me gustaría.

Syndicate_Admin
Administrator
Administrator

No @Jmccoy

¿Algo como esto?

//Last Month 
ADDCOLUMNS (
    GENERATE (
        SELECTCOLUMNS ( { "Last Month" }, "Period", [Value] ),
        GENERATESERIES (
            EDATE ( DATE ( ThisYear, ThisMonth, 1 ), -1 ),
            DATE ( ThisYear, ThisMonth, 1 ) - 1
        )
    ),
    "Axis Date", [Value] 
)

y similares para los demás

Por favor, marque la pregunta resuelta cuando haya terminado y considere dar un pulgar hacia arriba si las publicaciones son útiles.

Póngase en contacto conmigo de forma privada para obtener asistencia con cualquier necesidad de BI a gran escala, tutoría, etc.

Salud

SU18_powerbi_badge

Si aún así sigues teniendo problemas, zona de estar y de la semana pasada. Por favor, ayuda!!

Syndicate_Admin
Administrator
Administrator

@Jmccoy realizar este cambio en la expresión DAX para la lógica de los últimos 2 y 3 meses

instead of TODAY change it to

EOMONTH(Today,-1)

¡Muchas gracias!

Syndicate_Admin
Administrator
Administrator

Por favor, vea si este video ayuda. Es un enfoque diferente, pero puede crear las columnas para el día relativo, la semana, el mes, etc. que necesita para sus cálculos.

Power BI Tales From The Front - Indices de día/semana/mes/trimestre/año - YouTube

saludos

palmadita

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.