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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

DAX para calcular la misma semana del año anterior

Hola a todos. Estoy tratando de calcular qué ventas fueron para cada semana del año anterior. He creado una medida que se ve a continuación. Funciona bien para calcualte para cada semana. Sin embargo, deja de calcular el total cuando el rango de fechas se corssiona más de un año. ¿Cómo puedo solucionar esto? Gracias de antemano.

Amt Prior Yr = 
IF (
    HASONEVALUE ( DimDate[ISO_Year] ),
    CALCULATE (
        SUM(SalesFact[Amt]),
        FILTER (
            ALL ( DimDate ),
            DimDate[ISO_Year] = VALUES ( DimDate[ISO_Year] ) - 1
                && CONTAINS(
                    VALUES ( DimDate[ISO_WeekNum] ),
                     DimDate[ISO_WeekNum],
                     DimDate[ISO_WeekNum] )
        )
    ),
    BLANK()
)

La línea total funciona bien si en el mismo año:DataSundowner_0-1673468562294.png

La línea total deja de funcionar cuando hay varios años:DataSundowner_1-1673468621795.png

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

@DataSundowner Primero, por favor vote por esta idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

Esto parece un problema de totales de medida. Muy común. Vea mi publicación al respecto aquí: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Además, esta medida rápida, medir totales, la última palabra debería brindarle lo que necesita:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Además: https://youtu.be/uXRriTN0cfY
Y: https://youtu.be/n4TYhF2ARe8

Hola @Greg_Deckler Gracias por su rápida respuesta. Esa publicación de The Final Word resolvió mi problema. ¡Gracias!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.