Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Suggested answer

Concatenate without blank lines

Posted on by
Hi All,
 
I have the below working well in the way i wanted it to however want to tweak a little. at the moment the formula ignores if a question is blank giving me the below
 
Question 1: ABCDEFG

Question 2: HIJKLMN
Question 4: OPQRST
 
however I want it to look like this, any suggestions. the output text field will be used in an email notification.
 
Question 1: ABCDEFG
Question 2: HIJKLMN
Question 4: OPQRST
 
 
TrimEnds(Concatenate(
If(Q1_label.Text<>"",Q1_label.Text&" "),If(N1.Text<>"",N1.Text&" "),Char(13),Char(13),
If(Q2_label.Text<>"",Q2_label.Text&" "),If(N2.Text<>"",N2.Text&" "),Char(13),Char(13),
If(Q3_label.Text<>"",Q3_label.Text&" "),If(N3.Text<>"",N3.Text&" "),Char(13),Char(13),
If(Q4_label.Text<>"",Q4_label.Text&" "),If(N4.Text<>"",N4.Text&" "),Char(13),Char(13),
If(Q5_label.Text<>"",Q5_label.Text&" "),If(N5.Text<>"",N5.Text&" "),Char(13),Char(13),
If(Q6_label.Text<>"",Q6_label.Text&" "),If(N6.Text<>"",N6.Text&" "),Char(13),Char(13),
If(Q7_label.Text<>"",Q7_label.Text&" "),If(N7.Text<>"",N7.Text&" "),Char(13),Char(13),
If(Q8_label.Text<>"",Q8_label.Text&" "),If(N8.Text<>"",N8.Text&" "),Char(13),Char(13),
If(Q9_label.Text<>"",Q9_label.Text&" "),If(N9.Text<>"",N9.Text&" "),Char(13),Char(13),
If(Q10_label.Text<>"",Q10_label.Text&" "),If(N10.Text<>"",N10.Text&" "),Char(13),Char(13),
If(Q11_label.Text<>"",Q11_label.Text&" "),If(N11.Text<>"",N11.Text&" "),Char(13),Char(13),
If(Q12_label.Text<>"",Q12_label.Text&" "),If(N12.Text<>"",N12.Text&" "),Char(13),Char(13),
If(Q13_label.Text<>"",Q13_label.Text&" "),If(N13.Text<>"",N13.Text&" "),Char(13),Char(13),
If(Q14_label.Text<>"",Q14_label.Text&" "),If(N14.Text<>"",N14.Text&" "),Char(13),Char(13),
If(Q15_label.Text<>"",Q15_label.Text&" "),If(N15.Text<>"",N15.Text&" "),Char(13),Char(13),
If(Q16_label.Text<>"",Q16_label.Text&" "),If(N16.Text<>"",N16.Text&" "),Char(13),Char(13)))



 
  • Suggested answer
    Mclean2023 Profile Picture
    Mclean2023 79 on at
    Concatenate without blank lines
    Found a working solution: limiting the formula to only one field helped 
     
    Concatenate(
     
    If(!IsBlank(N1.Text), "Answer 1: " & N1.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N2.Text), "Answer 2: " & N2.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N3.Text), "Answer 3: " & N3.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N4.Text), "Answer 4: " & N4.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N5.Text), "Answer 5: " & N5.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N6.Text), "Answer 6: " & N6.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N7.Text), "Answer 7: " & N7.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N8.Text), "Answer 8: " & N8.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N9.Text), "Answer 9: " & N9.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N10.Text), "Answer 10: " & N10.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N11.Text), "Answer 11: " & N11.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N12.Text), "Answer 12: " & N12.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N13.Text), "Answer 13: " & N13.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N14.Text), "Answer 14: " & N14.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N15.Text), "Answer 15: " & N15.Text & Char(10) & Char(10), ""),
    If(!IsBlank(N16.Text), "Answer 16: " & N16.Text & Char(10) & Char(10), "")
     
    )
     
    Output now looks correct,
    If I update question 14 with an answers it adds correctly
  • Mclean2023 Profile Picture
    Mclean2023 79 on at
    Concatenate without blank lines
    Thanks for your quick reply, I have tried your suggestion but didn't have the outcome I was looking for, below is what I end up with
     
     
    Output I'm looking for
     
    Question 1: Comment 1
    Question 3: Comment 2
    Question 4: Comment 3
    Question 5: Comment 4
    Question 7: Comment 5
     
  • Suggested answer
    mmbr1606 Profile Picture
    mmbr1606 9,996 on at
    Concatenate without blank lines
    hey
     
    can u try this:
     
    TrimEnds(Concatenate(
        If(Q1_label.Text<>"" && N1.Text<>"", Q1_label.Text & ": " & N1.Text & Char(13), ""),
        If(Q2_label.Text<>"" && N2.Text<>"", Q2_label.Text & ": " & N2.Text & Char(13), ""),
        If(Q3_label.Text<>"" && N3.Text<>"", Q3_label.Text & ": " & N3.Text & Char(13), ""),
        If(Q4_label.Text<>"" && N4.Text<>"", Q4_label.Text & ": " & N4.Text & Char(13), ""),
        If(Q5_label.Text<>"" && N5.Text<>"", Q5_label.Text & ": " & N5.Text & Char(13), ""),
        If(Q6_label.Text<>"" && N6.Text<>"", Q6_label.Text & ": " & N6.Text & Char(13), ""),
        If(Q7_label.Text<>"" && N7.Text<>"", Q7_label.Text & ": " & N7.Text & Char(13), ""),
        If(Q8_label.Text<>"" && N8.Text<>"", Q8_label.Text & ": " & N8.Text & Char(13), ""),
        If(Q9_label.Text<>"" && N9.Text<>"", Q9_label.Text & ": " & N9.Text & Char(13), ""),
        If(Q10_label.Text<>"" && N10.Text<>"", Q10_label.Text & ": " & N10.Text & Char(13), ""),
        If(Q11_label.Text<>"" && N11.Text<>"", Q11_label.Text & ": " & N11.Text & Char(13), ""),
        If(Q12_label.Text<>"" && N12.Text<>"", Q12_label.Text & ": " & N12.Text & Char(13), ""),
        If(Q13_label.Text<>"" && N13.Text<>"", Q13_label.Text & ": " & N13.Text & Char(13), ""),
        If(Q14_label.Text<>"" && N14.Text<>"", Q14_label.Text & ": " & N14.Text & Char(13), ""),
        If(Q15_label.Text<>"" && N15.Text<>"", Q15_label.Text & ": " & N15.Text & Char(13), ""),
        If(Q16_label.Text<>"" && N16.Text<>"", Q16_label.Text & ": " & N16.Text & Char(13), "")
    ))
    
     
     
     
    if it works please mark as verified answer
     
    cheers
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard