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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Problema con la fórmula SWITCH

Hola

Intento escribir una fórmula SWITCH pero no ofrece autocompletar la tabla y la columna de mi tabla cuando introduzme el primer parámetro en la fórmula. Dice:

A single value for column 'ID' in table 'Products' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

¿Por qué sucede esto?

En segundo lugar, quiero escribir una fórmula CALCULATE fueron:

CALCULATE(COUNT(DifferentTable[Col1]),DifferentTable[Col2]=SameTable[Col1])

Traté de escribir:

CALCULATE(COUNT(DifferentTable[Col1]),DifferentTable[Col2]=RELATED(SameTable[Col1]))

¿Crees que funcionará? No he podido probar todavía debido al primer error.

Gracias

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hola, @UsePowerBI

Según su descripción, creé datos para reproducir su escenario. El archivo pbix se adjunta al final.

DifferentTable:

a1.png

SameTable:

a2.png

Puede crear una medida o una columna calculada como se muestra a continuación.

Calculated column:
Result Column = 
var _col1 = [Col1]
return
CALCULATE(
    DISTINCTCOUNT(DifferentTable[Col1]),
    FILTER(
        DifferentTable,
        DifferentTable[Col2] = _col1
    )
)

Measure:
Result Column = 
var _col1 = [Col1]
return
CALCULATE(
    DISTINCTCOUNT(DifferentTable[Col1]),
    FILTER(
        DifferentTable,
        DifferentTable[Col2] = _col1
    )
)

Resultado:

a3.png

Saludos

Allan

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

amitchandak
Super User
Super User

@UsePowerBI , la fórmula que puede haber probado con el filtro CALCULATE(COUNT(DifferentTable[Col1]),filter(DifferentTable,DifferentTable[Col2]-RELATED(SameTable[Col1])))

Si switch está en una medida, usted tiene el uso de asegurar un valor único como en un ejemplo dado

Switch( True(),
Max(Table[column]) á "19/20-P13", [Atrasado]
Max(Table[column]) á "20/21-P1" ,[Overdue]*0.9
Max(Table[column]) á "20/21-P2" ,[Overdue]*0.8
Max(Table[column]) á "20/21-P3" ,[Overdue]*0.7
Max(Table[column]) á "20/21-P4" ,[Overdue]*0.6
Max(Table[column]) á "20/21-P5" ,[Overdue]*0.5
Max(Table[column]) á "20/21-P6" ,[Overdue]*0.4
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak

Gracias, pero recibo este error:

The column 'SameTable[Col1]' either doesn't exist or doesn't have a relationship to any table available in the current context.

¿Alguna solución?

@UsePowerBI, funcionará desde la dirección 1-M. Así que cambiar filtro Tabla y columna relacionada

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Top Kudoed Authors