Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!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.
Hola
Estoy tratando de agregar una columna donde obtengo el primer valor más que ocurre en las columnas de una fila junto con el segundo valor más que ocurre, y el tercer valor más probable
Id | Columna1 | Columna2 | Columna3 | Columna4 | Columna5 |
1234 | manzana | manzana | Naranja | manzana | Naranja |
1235 | Naranja | Naranja | Pera | Naranja | Naranja |
En otras palabras, me gustaría una columna que mostraría "Apple" como el primer valor más que ocurre y "Naranja" como el segundo valor más que ocurre en la primera fila. ¿Cómo puedo hacer eso?
Solved! Go to Solution.
Hola, @RolandPlanet
He hecho algunos cambios en la medida. Por favor, pruebe la siguiente medida para ver si funciona.
Result =
var _id = SELECTEDVALUE('Table'[ID])
var tab =
SUMMARIZE(
'Table',
'Table'[ID],
'Table'[Value],
"Count",
COUNTROWS(
FILTER(
'Table',
'Table'[Value] = EARLIER('Table'[Value])
)
)
)
var newtab =
ADDCOLUMNS(
tab,
"Rank",
RANKX(
FILTER(
tab,
[ID] = _id
),
[Count]
)
)
return
CONCATENATEX(
FILTER(
newtab,
[Rank] = 1
),
[Value],
"-"
)&" "&
CONCATENATEX(
FILTER(
newtab,
[Rank] = 2
),
[Value],
"-"
)&" "&
CONCATENATEX(
FILTER(
newtab,
[Rank] = 3
),
[Value],
"-"
)
Saludos
Allan
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.
Hola, @RolandPlanet
Puede ir al Editor de consultas, ir a la cinta de opciones 'Transformar', hacer 'ID' seleccionado y hacer clic en 'despivotar otras columnas'. Y luego tienes que hacer clic en 'Cerrar y aplicar'.
Puede crear una medida como se muestra a continuación.
Result =
var _id = SELECTEDVALUE('Table'[ID])
var tab =
SUMMARIZE(
'Table',
'Table'[ID],
'Table'[Value],
"Count",
COUNTROWS(
FILTER(
'Table',
'Table'[Value] = EARLIER('Table'[Value])
)
)
)
var newtab =
ADDCOLUMNS(
tab,
"Rank",
RANKX(
FILTER(
tab,
[ID] = _id
),
[Count]
)
)
return
CONCATENATEX(
FILTER(
newtab,
[Rank] = 1
),
[Value]
)&" "&
CONCATENATEX(
FILTER(
newtab,
[Rank] = 2
),
[Value]
)&" "&
CONCATENATEX(
FILTER(
newtab,
[Rank] = 3
),
[Value]
)
Resultado:
Saludos
Allan
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.
¡Esto es genial! Sin embargo, si dos valores tienen el mismo número de ocurrencias, se concatenan juntos como "AppleOrange", por ejemplo. ¿Hay alguna manera de prevenir esto?
Hola, @RolandPlanet
He hecho algunos cambios en la medida. Por favor, pruebe la siguiente medida para ver si funciona.
Result =
var _id = SELECTEDVALUE('Table'[ID])
var tab =
SUMMARIZE(
'Table',
'Table'[ID],
'Table'[Value],
"Count",
COUNTROWS(
FILTER(
'Table',
'Table'[Value] = EARLIER('Table'[Value])
)
)
)
var newtab =
ADDCOLUMNS(
tab,
"Rank",
RANKX(
FILTER(
tab,
[ID] = _id
),
[Count]
)
)
return
CONCATENATEX(
FILTER(
newtab,
[Rank] = 1
),
[Value],
"-"
)&" "&
CONCATENATEX(
FILTER(
newtab,
[Rank] = 2
),
[Value],
"-"
)&" "&
CONCATENATEX(
FILTER(
newtab,
[Rank] = 3
),
[Value],
"-"
)
Saludos
Allan
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.
Mejor que los datos despivotados
https://radacad.com/pivot-and-unpivot-with-power-bi
A continuación, puede utilizar todas las expectativas a nivel de identificación para obtener esta respuesta
https://community.powerbi.com/t5/Desktop/Percentage-of-subtotal/td-p/95390
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.