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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

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

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors