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

Rankx con filtro de año

Buen día,

 

Tengo una tabla calculada con summarize de la siguiente forma:

Tabla ranking =
SUMMARIZE(Consolidado,
Consolidado[Razón social],
Consolidado[Año],
"Ventas", Consolidado[Ingresos ($M)],
"Activos", Consolidado[Activo ($M)],
"Ebitda", [Ebitda ($M)],
"Patrimonio", [Patrimonio ($M)])
Nota: Las variables ingresos, activos, ebitda y patrimonio son medidas calculadas a partir de una base de datos.
 
Necesito calcular el ranking de cada medida (ventas, activos, ebitda y patrimonio) para ello utilicé la siguiente fórmula solo para calcular el ranking de las ventas en este caso:
Ranking ventas =
IF(
ISBLANK('Tabla ranking'[Ventas]),
BLANK(),
RANKX(ALLSELECTED('Tabla ranking'),'Tabla ranking'[Ventas],,DESC,Dense))
Pero cuando me voy a la selección de informe, inserto una tabla y le agrego el filtro de año el ranking no se altera, es decir que no recalcula el ranking de la razón social discriminado por año, coje siempre la sumatoria de todos los años. Alguno sabe cómo solucionar esto? Muchas gracias.
1 ACCEPTED SOLUTION

Hi @pfinanciero ,

What you seem to have created is a calculated column, the value of a calculated column is computed during data refresh and uses the current row as a context. It does not depend on user interaction in the report. That's why you switch different years for the slicer, but the value of [Ranking ventas] remains the same...

You can create a measure  just as the ones in following links, unlike the calculated column, the measure operates on aggregations of data defined by the current context, which depends on the filter applied in the report – such as slicer, rows, and columns selection in a pivot table, or axis and filters applied to a chart.

Static vs Dynamic ranking in Power BI

DYNAMIC RANKX BY SLICER SELECTION IN POWER BI

yingyinr_0-1641451708270.png

Please find more details in the following links about the difference of calculated column vs measure.

Calculated Columns and Measures in DAX

Calculated Columns vs Measures

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@pfinanciero , As the ranking happening at the table level, I doubt addition of column from same table is going to make a difference

 

 

maybe you want to rank for

RANKX(ALLSELECTED('Tabla ranking'[Business name]),'Tabla ranking'[Ventas],,DESC,Dense)

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

La base de datos que tengo es así:

1.PNG

 Las medidas de ingresos, activos, ebitda y patrimonio son calculadas a partir de la columna saldo ($m), teniendo en cuenta el número de cuenta que está en la columna cuenta puc.

A partir de esa información creé la siguiente tabla calculada:

2.PNG

 En esta tabla calculada inserté una columna calculada con el nombre de "Ranking ventas":

Ranking ventas =
IF(
ISBLANK('Tabla ranking'[Ventas]),
BLANK(),
RANKX(ALLSELECTED('Tabla ranking'),'Tabla ranking'[Ventas],,DESC,Dense))
Cuando me dirijo a la sección de informe, inserto una tabla y le agrego el filtro de año me sucede lo siguiente:
3.PNG

 El ranking de ventas no tiene en cuenta el filtro del año, existe alguna solución para esto? Como podras observar ya utilicé el ALLSELECTED, lo estoy utilizando mal?

Hi @pfinanciero ,

What you seem to have created is a calculated column, the value of a calculated column is computed during data refresh and uses the current row as a context. It does not depend on user interaction in the report. That's why you switch different years for the slicer, but the value of [Ranking ventas] remains the same...

You can create a measure  just as the ones in following links, unlike the calculated column, the measure operates on aggregations of data defined by the current context, which depends on the filter applied in the report – such as slicer, rows, and columns selection in a pivot table, or axis and filters applied to a chart.

Static vs Dynamic ranking in Power BI

DYNAMIC RANKX BY SLICER SELECTION IN POWER BI

yingyinr_0-1641451708270.png

Please find more details in the following links about the difference of calculated column vs measure.

Calculated Columns and Measures in DAX

Calculated Columns vs Measures

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Solution Authors