Forum Discussion

Chapin4u's avatar
Chapin4u
Microsoft Employee
9 years ago
Solved

Line break in a visual

Hi, I'm trying to do a line break in a visual using unichar(10) but it's not working for me. It's possible to use a line break in card visual? This how I wrote the measure for the card:

 

Card Hotel Ave = SELECTEDVALUE(List[Grupo],"Todos")&": "&UNICHAR(10)&IF(SELECTEDVALUE(Hotels[currency],"Todos")="US$",FORMAT([Hotel Average Price],"$#,###.00"),IF(SELECTEDVALUE(Hotels[currency],"Todos")="GTQ","Q"&FORMAT([Hotel Average Price],"#,###.00"),FORMAT([Hotel Average Price],"#,###.00"

 

Thanks 

  • Hi Chapin4u,

    After research, we can not add line break in text directly, because Power BI always strips line breaks out of text when it gets loaded into the Data Model. unichar function returns the Unicode character that is referenced by the given numeric value. unichar(10) return a unicode in your measure, and it is recognised by a text. So it is not working for you. As I tested, unichar(10) returns nothing. What's your expected result? Please review more details about UNICHAR in this blog.

    Best Regards,
    Angelia


7 Replies

  • v-huizhn-msft's avatar
    v-huizhn-msft
    Microsoft Employee

    Hi Chapin4u,

    After research, we can not add line break in text directly, because Power BI always strips line breaks out of text when it gets loaded into the Data Model. unichar function returns the Unicode character that is referenced by the given numeric value. unichar(10) return a unicode in your measure, and it is recognised by a text. So it is not working for you. As I tested, unichar(10) returns nothing. What's your expected result? Please review more details about UNICHAR in this blog.

    Best Regards,
    Angelia


    • Chapin4u's avatar
      Chapin4u
      Microsoft Employee

      Thanks Angela for the explanation.

  • Anonymous's avatar
    Anonymous
    Not applicable

    I have managed to get a line break using UNICHAR(10) & UNICHAR(10240)

  • nimitchell's avatar
    nimitchell
    Frequent Visitor

    I have a solution to add new lines, separating text cells from a table. It is explained in more detail in my stack overflow post:

     

    Link to my solution

     

    It boils down to using `CONCATENATEX` on the cells that should be concatenated, providing the `UNICHAR(10)` statement as separator:

     

    CONCATENATEX(FILTER(Sheet1, [Column1]<>"Overview"), Sheet1[Column2], UNICHAR(10)))

     

    --> That is the defining line that can be seen in my screenshot on StackOverflow.

     

     

    EDIT: another user on SO suggested that this requires Release October 2017 and din't work on earlier versions!

  • Nadim131's avatar
    Nadim131
    Regular Visitor

    Turn off word wrap, and perhaps it will work for you. It will not look pretty though, if you have a different title background.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Follow UNICHAR(10) with " ", like this:

     

    "ABC" & UNICHAR(10) & " " & "DEF"

     

    Result:

    ABC

    DEF

     

    Hope that helps.

  • Hi,
    After reviewing a few answers here and combining solutions, I have found that this syntax for creating a measure works:

    VAR VALUES_TO_DISPLAY =
    CONCATENATEX( TABLE_NAME, COLUMN, UNICHAR(10) )
    RETURN
    IF(ISFILTERED(COLUMN), VALUES_TO_DISPLAY, "alt_text")

    In this example values from the filtered column can be shown with a line brake in card visuals when Format Visual settings -> Callout ->Value -> [Text wrap] is toggled on.