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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Saibal_78
Helper I
Helper I

Multiple KPIs with line break using BUTTON and SHAPE

Hi All,

 

I am trying to create a custom multiline KPIs using button/shape, below are my DAX codes, note I am not using card as left alignment is not possible in card. Any help would be highly appreciated.

 

Button/shape details:-

Button width = 350

Button height = 300

Monospace font used = Consolas

Horizontal Alignment of text = Left

Vertical Alignment of text = Top

 

DAX :-

Information Analytics1 =
VAR Space = " "
VAR CardWidth = 350
VAR Max_Text_Length = 45

VAR KPI1_Text = "Project Name :"
VAR KPI2_Text = "BOM :"
VAR KPI3_Text = "Region :"
VAR KPI4_Text = "NPV :"
VAR KPI5_Text = "IRR :"

VAR KPI1_Value = [ProjectName]
VAR KPI2_Value = [ProjectBOM]
VAR KPI3_Value = [ProjectRegion]
VAR KPI4_Value = [ProjectNPV]
VAR KPI5_Value = [ProjectIRR]

VAR KPI1_NumberOfSpaces_Left = Max_Text_Length - LEN(KPI1_Text)
VAR KPI2_NumberOfSpaces_Left = Max_Text_Length - LEN(KPI2_Text)
VAR KPI3_NumberOfSpaces_Left = Max_Text_Length - LEN(KPI3_Text)
VAR KPI4_NumberOfSpaces_Left = Max_Text_Length - LEN(KPI4_Text)
VAR KPI5_NumberOfSpaces_Left = Max_Text_Length - LEN(KPI5_Text)

VAR KPI1_NumberOfSpaces_Right = CardWidth - LEN(KPI1_Text)
VAR KPI2_NumberOfSpaces_Right = CardWidth - LEN(KPI2_Text)
VAR KPI3_NumberOfSpaces_Right = CardWidth - LEN(KPI3_Text)
VAR KPI4_NumberOfSpaces_Right = CardWidth - LEN(KPI4_Text)
VAR KPI5_NumberOfSpaces_Right = CardWidth - LEN(KPI5_Text)

VAR SummaryText =
    KPI1_Text & REPT(Space,KPI1_NumberOfSpaces_Left) & KPI1_Value & REPT(Space,KPI1_NumberOfSpaces_Right) &
    KPI2_Text & REPT(Space,KPI2_NumberOfSpaces_Left) & KPI2_Value & REPT(Space,KPI2_NumberOfSpaces_Right) &
    KPI3_Text & REPT(Space,KPI3_NumberOfSpaces_Left) & KPI3_Value & REPT(Space,KPI3_NumberOfSpaces_Right) &
    KPI4_Text & REPT(Space,KPI4_NumberOfSpaces_Left) & KPI4_Value & REPT(Space,KPI4_NumberOfSpaces_Right) &
    KPI5_Text & REPT(Space,KPI5_NumberOfSpaces_Left) & KPI5_Value

RETURN
    SummaryText
 
 
This is the output i got using above measure                         However this is the output I want
 
 Output I gotOutput I gotOutput I wantOutput I want 
4 REPLIES 4
cmandrad
New Member

I tried using the unichar(10) to add a line break to a Q&A action button and it didn't work
Do you know a workaround?

Saibal_78
Helper I
Helper I

No luck

@Saibal_78 

Can you send the sample file in private message? we are using this since years and it works.

rajulshah
Resident Rockstar
Resident Rockstar

@Saibal_78 

 

You can use the following DAX measure:

VAR SummaryText =
    KPI1_Text & REPT(Space,KPI1_NumberOfSpaces_Left) & KPI1_Value & REPT(Space,KPI1_NumberOfSpaces_Right) &UNICHAR(10)&
    KPI2_Text & REPT(Space,KPI2_NumberOfSpaces_Left) & KPI2_Value & REPT(Space,KPI2_NumberOfSpaces_Right) &UNICHAR(10)&
    KPI3_Text & REPT(Space,KPI3_NumberOfSpaces_Left) & KPI3_Value & REPT(Space,KPI3_NumberOfSpaces_Right) &UNICHAR(10)&
    KPI4_Text & REPT(Space,KPI4_NumberOfSpaces_Left) & KPI4_Value & REPT(Space,KPI4_NumberOfSpaces_Right) &UNICHAR(10)&
    KPI5_Text & REPT(Space,KPI5_NumberOfSpaces_Left) & KPI5_Value

 

UNICHAR(10) gives a line break.

Please let me know if this didn't help.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors