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
Anonymous
Not applicable

¿Cómo clasificar una columna con 2 categorías?

Oye

¿Podría alguien por favor ayudarme con el siguiente problema, por favor?

Tengo 2 x categorías con productos en cada uno y quiero clasificar el producto en valor, pero si es una nueva categoría quiero que este ranking también comience en 1.

A partir de eso también quiero agregar mis respectivas categorías a esa lista de productos y clasificar cada categoría como 1.
Esto es para que pueda trazar, ensalada, fruta y sus respectivos productos en un gráfico. Entonces si filtro en la parte superior 3 por ejemplo, mostrará mi salida deseada.
Mesa
CategoríaProductoValor
Frutamanzana9
FrutaPlátano8
FrutaNaranja7
EnsaladaLechuga4
EnsaladaTomate1
Salida deseada
NUEVO productoValorrango
manzana91
Plátano82
Naranja73
Lechuga41
Tomate12
Fruta241
Ensalada51
¿Alguien tiene alguna idea, por favor?
Gracias de antemano,
Lauren.
3 REPLIES 3
FrankAT
Community Champion
Community Champion

Hola @lauren1192,

qué pasa con la siguiente solución:

05-07-_2020_23-33-54.jpg

Saludos FrankAT

harshnathani
Community Champion
Community Champion

Hola @lauren1192 ,

Una pequeña modificación a la fórmula por @AllisonKennedy

New Table =
UNION (
    SUMMARIZECOLUMNS (
        'Table'[Product],
        "Value", SUM ( 'Table'[Value] ),
        "Rank", IF (
            MAX ( 'Table'[Product] )
                <> BLANK (),
            RANKX (
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Category]
                        = MAX ( 'Table'[Category] )
                ),
                CALCULATE (
                    SUM ( 'Table'[Value] )
                )
            )
        )
    ),
    SUMMARIZECOLUMNS (
        'Table'[Category],
        "Value", SUM ( 'Table'[Value] ),
        "Rank", IF (
            MAX ( 'Table'[Product] )
                <> BLANK (),
            RANKX (
                ALL ( 'Table'[Category] ),
                CALCULATE (
                    SUM ( 'Table'[Value] )
                )
            )
        )
    )
)

1.jpg

saludos

Harsh Nathani


Apreciar con un Kudos!! (Haga clic en el botón Pulgares arriba)

¿He respondido a tu pregunta? ¡Marca mi puesto como una solución!

AllisonKennedy
Super User
Super User

Podrías intentar:

Utilice SUMMARIZECOLUMNS para crear una nueva tabla de la salida deseada:

Tabla2-UNION(
RESUMCOLUMNS(Tabla[Producto], "Valor", SUMA(Tabla[Valor]), "Rank",
RANKX(
ALL('Table'[Category]) ,
CALCULATE(
SUM('Tabla'[Valor])
)
)),
RESUMCOLUMNS(Tabla[Categoría], "Valor", SUMA(Tabla[Valor]), "Rank", 1)

https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

O esto ayudará a obtener las filas para los productos solamente:

Puede agregar una columna a la tabla mediante RANKX, similar a este
Clasificar todas las filas como Columna (País)
RANKX(
FILTRO(
'Mesa',
'Tabla'[Categoría] - EARLIER('Tabla'[Categoría])
),
'Tabla de ventas'[Valor]
)
https://databear.com/how-to-use-the-dax-rankx-function-in-power-bi/

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.