Forum Discussion

amaral_diego's avatar
amaral_diego
Icon for Helper II rankHelper II
2 years ago
Solved

Help with Concatenate Text in Power BI

Hello everyone,

I’m trying to create a measure in Power BI that concatenates information from two related tables. Specifically, I want to display the phrase “Head: Professional Name (GESTOR)” where “Professional Name” comes from the d_Sócios table and “GESTOR” comes from the f_PRINCIPAL table.

The tables d_Sócios and f_PRINCIPAL are related by the columns Sigla (from d_Sócios) and GESTOR (from f_PRINCIPAL).

It's possible to do that in Power BI?

 

I am not able to get the measure to work correctly.
I've tried with the CONCATENATE, but without success.
Could someone help me correct this code or suggest a better approach?

Also, would it be better to do this with DAX code or by concatenating directly in a text box?

Thank you in advance for your help!

  • FreemanZ's avatar
    FreemanZ
    2 years ago

    hi amaral_diego ,

     

    then try like:

    measure =

    MAXX(RELATEDTABLE(d_Sócios),d_Sócios[Professional Name])

    &

    MAX(f_PRINCIPAL[GESTOR])

  • Thanks for your assistance, but I've found another way more familiar to do.

5 Replies

  • hi amaral_diego 

     

    how are they related?

    Supposing d_Sócios is on the one side, try like:

    measure =

    MAX(d_Sócios[Professional Name])

    &

    MAXX(RELATEDTABLE(f_PRINCIPAL), f_PRINCIPAL[GESTOR])

    • amaral_diego's avatar
      amaral_diego
      Icon for Helper II rankHelper II

      I've tried with your code, without success,
      they are related many to one
      many from GESTOR Column from the table f_PRINCIPAL
      one from Sigla Column from the table d_Sócios

      I now how to do it in power apps
      is something like that
      Text = "Head: " & LookUp(d_Sócios, ID = ThisItem.ID, [Nome Profissional]) & " (" & LookUp(f_PRINCIPAL, ID = ThisItem.ID, [GESTOR]) & ")"

      I need to know, if is possible to do something similiar on Power BI

      • FreemanZ's avatar
        FreemanZ
        Icon for Super User rankSuper User

        hi amaral_diego ,

         

        then try like:

        measure =

        MAXX(RELATEDTABLE(d_Sócios),d_Sócios[Professional Name])

        &

        MAX(f_PRINCIPAL[GESTOR])

  • Hi amaral_diego 
    You can use the below DAX:

    HeadInfo ="Head: " & SELECTEDVALUE(d_Sócios[Professional Name]) & " (" & LOOKUPVALUE(f_PRINCIPAL[GESTOR], f_PRINCIPAL[Sigla], d_Sócios[Sigla]) & ")"

    Explanation

    1. SELECTEDVALUE(d_Sócios[Professional Name]): This function retrieves the Professional Name from the d_Sócios table. SELECTEDVALUE is helpful here as it returns the single value in a context, or blank if there are multiple.

    2. LOOKUPVALUE(f_PRINCIPAL[GESTOR], f_PRINCIPAL[Sigla], d_Sócios[Sigla]): This function looks up the GESTOR value in f_PRINCIPAL based on the matching Sigla in d_Sócios. It will return the value from f_PRINCIPAL if there is a unique match.

    3. Concatenation: The & operator is used to concatenate the strings with custom text as specified.

    • Make sure your relationship between d_Sócios[Sigla] and f_PRINCIPAL[Sigla] is set up correctly in the model.
    • This measure should be placed in a visual that has context for d_Sócios[Sigla] so that SELECTEDVALUE can retrieve the correct Professional Name.

    Alternative: Concatenation in a Calculated Column

    If you need the result at a row level rather than a measure, you could also create a calculated column instead of a measure, using similar logic.

    Let me know if you need further customization!

    Give "Kudos" if you find it helpful! Happy Learning!! 🙂