Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Concat Dropdown items with if condition

(0) ShareShare
ReportReport
Posted on by 178

Hi Guys,

 

In my dropdown list I'm showing two items from my collection with the below code. This works fine.

 

SortByColumns( AddColumns(Types, "Mod&Des", Concatenate(MType, " - ", Description)), "Mod&Des")

 

 

However, when I'm missing either a Mtype or Description its still adding in the "-" as this is a string and will be included for every line of my collection.

 

Is there a way to add in an if formula when say the Description or Type is empty not to add in the "-", and only add it in when both values are there.

 

Any help is greatly appreciated.

 

Thanks

  • Verified answer
    Re: Concat Dropdown items with if condition

    Hi @christian12 ,

     

    Please try:

    SortByColumns(AddColumns(FH,"Mod&Des",If(IsBlank(Mtype),Description,IsBlank(Description),Mtype,Concatenate(Mtype,"-",Description))),"Mod&Des")

    vdezhilimsft_1-1673925703950.png

    vdezhilimsft_0-1673925614080.png

     

    Best Regards,

    Dezhi

  • christian12 Profile Picture
    christian12 178 on at
    Re: Concat Dropdown items with if condition

    No there not choice names

     

    Collection name:  Type

    MtypeDescription 
    22 
    33Blue
     Black
    44Pink

     

    End Result will look like this. (with also the sort functionality)

    MtypeDescription Mod&Des
    22 22
    33Blue33 - Blue
     BlackBlack
    44Pink44 - Pink

     

    The code for some reason doesnt work. I get the error column name conflict for 'Mod&Des'

  • Drrickryp Profile Picture
    Drrickryp on at
    Re: Concat Dropdown items with if condition

    @christian12

    If they are choice columns you need to append .Value to the column names

     

  • christian12 Profile Picture
    christian12 178 on at
    Re: Concat Dropdown items with if condition

    @Drrickryp 

     

    Thanks although I'm getting an if error.

     

    FYI the Mtype & Description are two separate columns  in my Types collection. 

    Unsure if it is the IsBlank part of the code as it is not pointing to a collection/column which might be causing the error.

     

    Thanks again

  • Drrickryp Profile Picture
    Drrickryp on at
    Re: Concat Dropdown items with if condition

    @christian12 

     

    With({ccat: If(IsBlank(MType),Description,
     IsBlank(Description), MType,
     Concatenate(MType, " - ", Description)
     )},
     SortByColumns(AddColumns(Types, "Mod&Des", ccat, "Mod&Des", Ascending)
    )

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard