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
brandonchan
Frequent Visitor

Crear medida para la misma columna

Hola

Soy un principiante de la consulta de energía y he importado una consulta de SQL y crear una matriz visual. En Valores, arrastro la columna "Coste total". En Columnas, arrastro la columna "Fecha". Como mis datos contienen datos en 2019 y 2020, en los objetos visuales de matriz se muestra en 2 columnas. ¿Cómo puedo crear una medida para mostrar la diferencia y el % de cambio del coste total entre 2019 y 2020?

Nombre 2019 2020 Total

Un $20 $25 $45

B $30 $28 $58

C $40 $35 $75

Gracias

3 REPLIES 3
Icey
Community Support
Community Support

Hola @brandonchan ,

¿Está resuelto este problema?


Si se resuelve, por favor acepte siempre las respuestas que tienen sentido como solución a su pregunta para que las personas que pueden tener la misma pregunta puedan obtener la solución directamente.


Si no, por favor hágamelo saber.


Saludos
Icey

Icey
Community Support
Community Support

Hola @brandonchan ,

Prueba esto:

1. Cree una tabla Calendario.

Calendar = CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) )

2. Crear relación.

rela.PNG

3. Crear medidas.

Difference = 
VAR Current_ =
    SUM ( 'Table'[Total Cost] )
VAR Previous_ =
    CALCULATE (
        SUM ( 'Table'[Total Cost] ),
        SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
    )
RETURN
    Current_ - Previous_
% Difference = 
VAR Current_ =
    SUM ( 'Table'[Total Cost] )
VAR Previous_ =
    CALCULATE (
        SUM ( 'Table'[Total Cost] ),
        SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
    )
RETURN
    DIVIDE ( Current_ - Previous_, Previous_ )

4. Cree un objeto visual Matrix.

diff.PNG

Saludos

Icey

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

amitchandak
Super User
Super User

Si son una columna de su tabla, entonces puede usar

Diff á [2020]-[2019]

Pero si son como valores de fila. O lo dow mediante el uso de unpivot

https://radacad.com/pivot-and-unpivot-with-power-bi

Después de ese año sería una columna. crear una mesa de año nuevo y hacerlo así

this year = 
CALCULATE(SUM(Sales[Sales Amount]),filter(all(Year),Year[Year]=Max(Year[Year])))


last year = 
CALCULATE(SUM(Sales[Sales Amount]),filter(all(Year),Year[Year]=Max(Year[Year])))

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.