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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Sandeep_PBI
Frequent Visitor

Comparar columnas en función de una selección de usuario

Tengo una tabla con columnas (Student ID, Category, 2017,2018,2019,2020). a continuación se muestra el ejemplo

f.PNG

Tengo una segmentación (lista desplegable) en el informe que muestra años distintos (2018,2019,2020).

La tarea que estoy tratando de completar es mostrar un informe con una tabla como sigue (por ejemplo, suponiendo que el usuario seleccionado 2018 en la segmentación de datos y los resultados basados en los datos de ejemplo anteriores deben ser los siguientes) que muestra si el estudiante cambió la selección en comparación con la selección año anterior (2017 en el siguiente caso) basado en el año seleccionado de la cortadora (2018 para el).

r.PNG

He intentado varias maneras, pero no pude obtener la salida deseada. ¿cómo se puede lograr esto usando DAX?

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hola , @Sandeep_PBI

Pruebe la medición como se muestra a continuación:

change =
VAR _id =
    SELECTEDVALUE ( Category[Student ID] )
VAR _category =
    SELECTEDVALUE ( Category[Category] )
VAR _year =
    SELECTEDVALUE ( Category[Year] )
RETURN
    IF (
        CALCULATE (
            CONCATENATEX ( Category, Category[Value] ),
            FILTER (
                ALL ( Category ),
                Category[Student ID] = _id
                    && Category[Category] = _category
                    && Category[Year] = _year - 1
            )
        )
            = SELECTEDVALUE ( Category[Value] ),
        0,
        1
    )

Aquí hay una demostración.

Pbix adjunto

Saludos
Equipo de Apoyo Comunitario _ Eason
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.

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hola , @Sandeep_PBI

Pruebe la medición como se muestra a continuación:

change =
VAR _id =
    SELECTEDVALUE ( Category[Student ID] )
VAR _category =
    SELECTEDVALUE ( Category[Category] )
VAR _year =
    SELECTEDVALUE ( Category[Year] )
RETURN
    IF (
        CALCULATE (
            CONCATENATEX ( Category, Category[Value] ),
            FILTER (
                ALL ( Category ),
                Category[Student ID] = _id
                    && Category[Category] = _category
                    && Category[Year] = _year - 1
            )
        )
            = SELECTEDVALUE ( Category[Value] ),
        0,
        1
    )

Aquí hay una demostración.

Pbix adjunto

Saludos
Equipo de Apoyo Comunitario _ Eason
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.

rajulshah
Resident Rockstar
Resident Rockstar

Hola @Sandeep_PBI,

Debe anular el pivote de las columnas y, a continuación, utilizar la medida.

Por favor, vea a continuación mi consulta M a continuación:

let
    Source = *Your Source Here*,
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Student ID", Int64.Type}, {"Category", type text}, {"2017", type text}, {"2018", type text}, {"2019", type text}, {"2020", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Student ID", "Category"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Year"}})
in
    #"Renamed Columns"

Y luego puede usar la siguiente medida:

Change = 
VAR SelectedYear = IF(NOT(ISFILTERED(Category[Year])),MAX(Category[Year]),SELECTEDVALUE(Category[Year]))
VAR ValueSelectedYear = MINX(FILTER(Category,Category[Year]=2020),Category[Value])
VAR ValuePreviousYear = CALCULATE(MIN(Category[Value]),ALL(Category[Year]),Category[Year]=SelectedYear-1)
RETURN IF(ValuePreviousYear=ValueSelectedYear,1,0)


Espero que esto ayude.

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

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

Top Solution Authors
Top Kudoed Authors