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
Anonymous
Not applicable

Semana actual vs semana anterior (mismo año)

Me gustaría crear un gráfico de líneas que muestre mi semana actual frente a la semana pasada de un valor total. Sé que necesito 2 medidas aquí, pero las ecuaciones de base de tiempo de la semana que he probado no están funcionando.

Tengo mi calendario de fechas con el número de semana y el número del día de la semana (el domingo comienza la semana para nosotros).

¿Alguien ha tenido alguna oportunidad con conseguir que esto funcione? Cualquier ejemplo que he encontrado no funciona para mí. ¡Gracias!

1 ACCEPTED SOLUTION
edhans
Super User
Super User

He hecho un trabajo extenso con semanas. Lo que utilizo es la siguiente lógica:

  • Obtenga el número de semana actual de sus datos. Algo como esto:
Prior Year Sales = 
VAR CurrentWeek =
    MAXX(
        'Sales',
        RELATED( 'Date'[Week of Year] )
    )
VAR CurrentYear =
    MAXX(
        'Sales',
        RELATED( 'Date'[Year] )
    )
VAR PriorYearSales =
    SUMX(
        FILTER(
            ALL( Sales ),
            RELATED( 'Date'[Year] ) = CurrentYear - 1
                && RELATED( 'Date'[Week of Year] ) = CurrentWeek
        ),
        Sales[SubTotal]
    )
RETURN
    PriorYearSales

Usted una ver las ventas de la semana 2011 23-26 están mostrando en el año anterior para 2012 para esas mismas semanas.

2020-06-01 13_28_36-Untitled - Power BI Desktop.png

Aquí hay un enlace a mi archivo PBIX si desea jugar con él.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hola, @Dawn_K

Si usted toma la respuesta de alguien, por favor márquela como la solución para ayudar a los otros miembros que tienen los mismos problemas a encontrarla más rápidamente. Si no, avísame y trataré de ayudarte más. Gracias.

Saludos

Allan

v-alq-msft
Community Support
Community Support

Hola, @Dawn_K

Según su descripción, creé datos para reproducir su escenario. El archivo pbix se adjunta al final.

Mesa:

d1.png

Puede crear una columna calculada y una medida como bleow.

Calculated column:
Weeknum = WEEKNUM('Table'[Date])

Measure:
LastWeekValue = 
var _lastweeknum = SELECTEDVALUE('Table'[Weeknum])-1
var _result = 
CALCULATE(
    SUM('Table'[Value]),
    'Table'[Weeknum] = _lastweeknum
)
return
_result

Resultado:

d2.png

Saludos

Allan

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

edhans
Super User
Super User

He hecho un trabajo extenso con semanas. Lo que utilizo es la siguiente lógica:

  • Obtenga el número de semana actual de sus datos. Algo como esto:
Prior Year Sales = 
VAR CurrentWeek =
    MAXX(
        'Sales',
        RELATED( 'Date'[Week of Year] )
    )
VAR CurrentYear =
    MAXX(
        'Sales',
        RELATED( 'Date'[Year] )
    )
VAR PriorYearSales =
    SUMX(
        FILTER(
            ALL( Sales ),
            RELATED( 'Date'[Year] ) = CurrentYear - 1
                && RELATED( 'Date'[Week of Year] ) = CurrentWeek
        ),
        Sales[SubTotal]
    )
RETURN
    PriorYearSales

Usted una ver las ventas de la semana 2011 23-26 están mostrando en el año anterior para 2012 para esas mismas semanas.

2020-06-01 13_28_36-Untitled - Power BI Desktop.png

Aquí hay un enlace a mi archivo PBIX si desea jugar con él.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
parry2k
Super User
Super User

@Dawn_K tantas publicaciones y videos sobre esto, algunos enlaces aquí, si ninguno funciona, comparten datos y explican lo que no está funcionando

https://www.youtube.com/watch?v=jclWnA7pEvY

https://www.youtube.com/watch?v=2ya3pdgemP4

https://www.youtube.com/watch?v=jBPLm5BHl2c

Me gustaría elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.