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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Syndicate_Admin
Administrator
Administrator

Inteligencia de tiempo en variaciones con filtro de fecha

Hola, como estan?

Estoy necesitando poder realizar variaciones de cantidad de ventas en base a un filtro de fecha. Por ejemplo si en el filtro tengo seleccionado un mes que de la variacion respecto del mes anterior, si esta seleccionada un año me muestre la variación del año anterior, pero tambien necesito si esta seleccionado un día en el filtro me de la variacion con el dia anterior o si esta seleccionado en el filtro una semana que me muestre la variación respecto de la semana anterior, todo en base al mismo filtro. Es decir el periodo "-1" de lo que este filtrado.

Alguien sabe como realizarlo?

Muchas gracias!

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Hola @AgustinE ,

Basándome en su descripción, creé muestras simples y puede verificar los resultados de la siguiente manera:

Tabla original:

vtianyichmsft_0-1701413557745.png

Por año:

vtianyichmsft_1-1701413575753.png

Por mes:

vtianyichmsft_2-1701413598797.png

Por semana:

vtianyichmsft_3-1701413658117.png

DimDate = 
ADDCOLUMNS (
    CALENDARAUTO (),
    "Year", YEAR ( [Date] ),
    "Month", FORMAT ( [Date], "MMMM" ),
    "MonthSort", MONTH ( [Date] ),
    "Day", DAY ( [Date] ),
    "DayName", FORMAT ( [Date], "DDDD" ),
    "WeekDay", WEEKDAY ( [Date],2 ),
    "WeekStart",
        [Date] - WEEKDAY ( [Date], 2 ) + 1
)

Last=
SWITCH (
    TRUE (),
    DISTINCTCOUNT ( DimDate[Year] ) = 1
        && DISTINCTCOUNT ( DimDate[Month] ) = 12, CALCULATE ( SUM ( 'Table'[Value] ), SAMEPERIODLASTYEAR ( DimDate[Date] ) ),
    DISTINCTCOUNT ( DimDate[Month] ) = 1
        && DISTINCTCOUNT ( DimDate[WeekStart] ) > 1, CALCULATE ( SUM ( 'Table'[Value] ), PREVIOUSMONTH ( DimDate[Date] ) ),
    DISTINCTCOUNT ( DimDate[WeekStart] ) = 1,
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( ALL ( DimDate ), DimDate[WeekStart] = MAX ( DimDate[WeekStart] ) - 7 )
        ),
    CALCULATE ( SUM ( 'Table'[Value] ) )
)

Un archivo adjunto para su referencia. ¡Espero que te ayude!

Saludos
Apoyo a la comunidad Team_ Scott Chang

Si esta publicación ayuda, considere aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

Syndicate_Admin
Administrator
Administrator

Suena sencillo. ¿Qué has probado y dónde estás atascado?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors