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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
wquayle
Frequent Visitor

Gráfico de barras comparando el volumen mensual con el volumen mensual promedio YTD

Necesito crear un gráfico de barras que muestre el total mensual actual en 3 categorías separadas (Categoría 1, 2, 3) y también muestre el volumen mensual promedio YTD para las tres categorías. El objetivo es mostrar cómo el volumen de meses actual para cada categoría se compara proporcionalmente al volumen YTD.

Puedo crear el gráfico de barras con volumen de enero a mayo de 2020 para cada categoría, pero no puedo crear una línea que muestre el volumen YTD promedio para cada categoría debido al filtro mensual en el gráfico de barras. ¿Necesito usar DAX para superar este problema? ¿Agradecería ayuda?

6 REPLIES 6
v-gizhi-msft
Community Support
Community Support

Hola

Por favor, pruebe estas medidas:

Current Month = 
IF (
    MONTH ( MAX ( 'Table'[Date] ) ) = MONTH ( TODAY () ),
    SUM ( 'Table'[Values] )
)
YTD = 
VAR a =
    SUMMARIZE (
        ALLSELECTED ( 'Table' ),
        'Table'[Date],
        'Table'[Category],
        "YTD", CALCULATE (
            SUM ( 'Table'[Values] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Category] IN FILTERS ( 'Table'[Category] )
                    && 'Table'[Date] <= MAX ( 'Table'[Date] )
            )
        )
    )
RETURN
    AVERAGEX ( FILTER ( a, [Date] IN FILTERS ( [Date] ) ), [YTD] )

El resultado muestra:

10.PNG

Vea mi archivo pbix adjunto.

Saludos

Giotto

parry2k
Super User
Super User

@wquayle sí tienes que crear una medida para calcular YTD avg. Como práctica recomendada, agregue la dimensión de fecha en el modelo y utilelo para los cálculos de inteligencia de tiempo y tiempo. Una vez agregada la dimensión de fecha, márquela como una tabla de fechas en las herramientas de tabla.

https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-ca...

YTD AVG = CALCULATE ( AVERGATE( Table[Column] ), DATESYTD ( DateTable[Date] ) ) 

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.

Agradecemos su respuesta y absolutamente proporcionará Kudos. Cuando uso la fórmula de su sitio la fecha, recibo el siguiente mensaje de error, "La columna 'Año' en la tabla 'Fecha' tiene enlaces no válidos especificados." He eliminado esta línea de código y recibí otro mensaje, "La columna Mes' en la tabla 'Fecha' tiene enlaces no válidos especificados. ¿Puede aconsejar cómo resolver este problema? ¡Gracias, otra vez!

@wquayle está relacionado con mi publicación? ¿A qué te refieres también?



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.

Hola

Si mi respuesta anterior ha resuelto su problema, márquelo como una solución para que otros lo vean.

Saludos

Giotto

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Top Kudoed Authors