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

¿Puedo establecer un nombre de columna como variable en DAX?

Hola 🙂

Quiero poder cambiar el nombre de la columna a la que se hace referencia en una fórmula DAX - por ejemplo aquí quiero poder cambiar el nombre de la columna donde dice "YTD", de modo que esto se base en una selección de segmentación de datos

djalexr_0-1600355286864.png

Es lo suficientemente fácil para cambiar los otros valores (por ejemplo, . Hice una fórmula que usa una entrada de segmentación de datos en lugar del valor "Turnover" codificado de forma rígida en la fórmula anterior... pero me pregunto si es posible también hacer que el nombre de la columna entre corchetes una variable?

¿Es posible?

¡¡Gracias!!

Alex

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@djalexr No exactamente dentro de los corchetes, pero podría probar una función SWITCH para obtener el resultado que busca:

AllisonKennedy_0-1600605935512.png

Este es un ejemplo que inventé:

Columna de segmentación de pruebas ( Test Slicer Column)


SUMX(FILTER('Valores en blanco',
SER _Column ?
SWITCH(SELECTEDVALUE(Slicer[Column Select])
, "Año", 'Valores en blanco'[Año]
, "Key", 'Blank Values'[Key])
devolución
CONTAINSSTRING(_Column ,"2018")), 'Valores en blanco'[Valor])

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

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

¡Muchas gracias por esto! Sí, pude solucionar esto usando la función SWITCH.

Gracias de nuevo

Alex

¡De nada!

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

AllisonKennedy
Super User
Super User

@djalexr No exactamente dentro de los corchetes, pero podría probar una función SWITCH para obtener el resultado que busca:

AllisonKennedy_0-1600605935512.png

Este es un ejemplo que inventé:

Columna de segmentación de pruebas ( Test Slicer Column)


SUMX(FILTER('Valores en blanco',
SER _Column ?
SWITCH(SELECTEDVALUE(Slicer[Column Select])
, "Año", 'Valores en blanco'[Año]
, "Key", 'Blank Values'[Key])
devolución
CONTAINSSTRING(_Column ,"2018")), 'Valores en blanco'[Valor])

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

Sé que llego muy tarde a la fiesta. Pero, ¿es factible obtener el archivo de ejemplo pbix que hace esto?

no te preocupes, me parece cómo hacerlo? 🙂

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.