cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
slhangen
Helper V
Helper V

With Function

Need help on With code.

I have 2 fields I need to put together in a string:
1) cbStrengthSelections.SelectedItems
2) iptAddStrength.Text

 

If there is no selection from cbStrengthSelections.SelectedItems, I just need to display iptAddStrength.Text.
If there are items from cbStrengthSelections.SelectedItems. I need to display those and separate using a semicolon ;

 

Thx for any assistance

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@slhangen 

Yes, your formula has issues and seeing what you have clarifies what you are trying to do.

Your formula should be the following:

   Concat(cbStrengthSelections.SelectedItems, 'Strengths (Strengths)' & "; ") & iptAddStrength.Text

 

If there are no selected items it will just be the value of iptAddStrength.Text.  If there are selected items, then they will be first with semi-colon separation and then the value of iptAddStrength

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

11 REPLIES 11
RandyHayes
Super User
Super User

@slhangen 

Consider setting your formula to the following:

If(CountRows(cbStrengthSelections.SelectedItems)=0,

   iptAddStrength.Text,

   Concat(cbStrengthSelections.SelectedItems, yourColumn, ";")
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thx for your reply.  Unfortunately, I am not getting back my results of cbStrengthSelections.SelectedItems,

only iptAddStrength.Text.

 

I want to concatenate results of any or both fields that have data. Stumped (facepalm)

RandyHayes
Super User
Super User

@slhangen 

What does your formula look like at this point? And, what is the Items property of cbStrengthSelections?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
logixcrm
Helper I
Helper I

HI @slhangen 

 

Here is a very similar approach to what Randy is suggesting. Hope this helps

 

I am not sure if you used a combo box or list.... should not matter though, the formula still works, below is the result

List.JPG

 

here is the formula I used

 

 

If(
    CountRows(cbStrengthSelections.SelectedItems) = 0,
    Concat(
        iptAddStrength.SelectedItems,
        Value,
        "; "
    ),
    Concat(
        cbStrengthSelections.SelectedItems,
        Value,
        "; "
    ) & Concat(
        iptAddStrength.SelectedItems,
        Value,
        "; "
    )
)

 

 

 

RandyHayes
Super User
Super User

@logixcrm 

I am not seeing that @slhangen 's  iptAddStrength is a combobox as it was using the .Text property.  I believe that is a TextInput control.

 

However, the initial title was help with With.  I didn't see a specific need based on the requirements stated, so I skipped that, but in your formula, I do see a need.

With({_iptItems: Concat(iptAddStrength.SelectedItems, Value, "; ")},

    If(CountRows(cbStrengthSelections.SelectedItems) = 0, 
        _iptItems,

        Concat(cbStrengthSelections.SelectedItems, Value, "; ") & _iptItems
    )
)

Anyway...just thought this post needed something with a With since it was titled that way. 😁

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Yes, fellas. iptItems is a TextInput control.

 

I tried to sub this in your provided formulas but I still can't get it to work. 

I suppose I could set the combo box results to a variable but I think the With formula is a better alternative. I just can't get my mind around it yet.

 

I am trying to build skills for projects going forward.

 

Thx again, guys.

 

Items for cbStrengthSelections are:

 

Filter(Strengths, Consideration = cbStrengthArea.Selected.Result)

RandyHayes
Super User
Super User

@slhangen 

So what does your formula look like at this point?  Can you show that to get a better Idea on what you are seeing?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Concat(cbStrengthSelections.SelectedItems, 'Strengths (Strengths)' & "; "&iptAddStrength.Text)

 

It works unless there are no selections from cbStrengthSelections.  And sometimes there won't be.

Pereplexed.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,422)