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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

Relaciones

Hola

Tengo 2 columnas que provienen del cliente, por ejemplo, ID1 e ID2 (tabla de hechos)

Establezco relación con dim_emp entre (Dim_ID1) y (Fact_ID1 )

La relación funciona bien para la mayoría de los agentes

pero tengo un problema que algunos agentes que provienen del cliente no tienen ID1 pero tienen ID2

así que quiero decirle a Power BI si no encontró ID1, así que haga la relación con ID2

¿Cómo puedo hacer eso?

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Hola @ahmedshalabyy12,

Espero que hayan tenido la oportunidad de revisar la solución compartida por @Shivu-2000 . Si abordó su pregunta, considere aceptarlo como la solución: ayuda a otros a encontrar respuestas más rápidamente.
Si sigues teniendo el problema, no dudes en responder y estaremos encantados de ayudarte.

Gracias.

Syndicate_Admin
Administrator
Administrator

Hola @ahmedshalabyy12

Según tengo entendido, sus datos son los siguientes:

Tiene una tabla Fact que contiene dos columnas de ID del cliente:

  • ID1

  • ID2

    You also have a Dimension table (Dim_Emp) with the column:

    • Dim_ID1

      Actualmente, ha creado una relación entre:

Fact[ID1] → Dim_Emp[Dim_ID1]

This works fine for most agents.
However, for some records, ID1 is blank or missing, but ID2 has a valid value.
You want Power BI to fall back to use ID2 when ID1 is not available for establishing the relationship.
My solution to this will be create a
new Calculated column the Fact table that acts as a fallback ID by checking ID1 first, and using ID2 if ID1 is blank.

Paso 1: Agregar una columna calculada

En Power BI, vaya a la tabla de hechos y cree una nueva columna con el siguiente DAX:

Effective_ID = IF ( NOT ISBLANK(Fact[ID1]), Fact[ID1], Fact[ID2] )

Paso 2: Actualizar la relación

En la vista de modelo:

  • Delete the existing relationship between Fact[ID1] and Dim_Emp[Dim_ID1]

  • Cree una nueva relación entre:

Fact[Effective_ID] → Dim_Emp[Dim_ID1]

This ensures Power BI uses ID1 when it’s present, and falls back to ID2 otherwise.

Si esta publicación ayuda, considere Acéptalo como la solución para ayudar a los demás miembros a encontrarlo más rápidamente.
¡Feliz de ayudar!

Gracias que funcionó aperci su esfuerzo

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors