cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RickJ
Advocate I
Advocate I

Format Currency Text Returns Blank with 0 Input

I want to Format text coming from a sum of two other inputs in currency format.

 

- I can either have nice formatting 000,000,000 and not show a 0 if the text being formatted is 0 

- OR I can show a 0 but I loose the number formatting

 

Text(Sum(Value(txtInput1.Text),Value(txtInput2.Text), "[$-en-US]###,###,###"))  = shows 0 but no formatting

Text(Text(Sum(Value(txtInput1.Text),Value(txtInput2.Text)), "[$-en-US]###,###,###"))  = shows formatting but if 0 it shows blank

 

Any options here to use formatting if numbers input and of sum = 0 still show 0??

 

- I tried and If statement to detect if sum = 0 just return 0 not through format string, but formatting doesn't like to be in a if statement either

1 ACCEPTED SOLUTION

Accepted Solutions
zmansuri
Super User
Super User

If(IsBlank(TextInput1)&&IsBlank(TextInput2),"0",Text(Sum(Value(TextInput1.Text),Value(TextInput2.Text)),"###,###,###"))

View solution in original post

5 REPLIES 5
v-xiaochen-msft
Community Support
Community Support

Hi @RickJ ,

 

You could create 2 lables to show value.

If the value is 0, label1 is displayed.

If the value is not 0, label2 is displayed

 

For example:

Label1 Visible:

If(Sum(Value(TextInput1.Text),Value(TextInput2.Text),"[$-en-US]  ###,###,###")=0,true,false)

Label1 Text:

0

 

Label2 Visible:

 

If(Sum(Value(TextInput1.Text),Value(TextInput2.Text),"[$-en-US]  ###,###,###")<>0,true,false)

 

Label2 Text:

Text(Sum(Value(TextInput1.Text),Value(TextInput2.Text)),"[$-en-US]  ###,###,###")

 

Finally, overlap the positions of these two controls.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

Liam_Chapman
Resolver II
Resolver II

Hi @RickJ ,

I think the below should work:


Text(Sum(Value(TextInput1.Text),Value(TextInput2.Text)), If(Sum(Value(TextInput1.Text),Value(TextInput2.Text)) = 0,"0","[$-en-US]###,###,###"))

 

Liam_Chapman_0-1622792719070.png

Liam_Chapman_1-1622792732370.png

 

So do the if statement around the format string instead of the value.

 

Thanks,
Liam

 

zmansuri
Super User
Super User

If(IsBlank(TextInput1)&&IsBlank(TextInput2),"0",Text(Sum(Value(TextInput1.Text),Value(TextInput2.Text)),"###,###,###"))

Thanks great solutions, and I just added in the handle for 0 as well as blanks and it works great.

 

 

If(
    (IsBlank(TextInput1)||TextInput1.Text="0")&&(IsBlank(TextInput2)||TextInput2.Text="0"),
    "0",
    Text(Sum(Value(TextInput1.Text),Value(TextInput2.Text)),"###,###,###")
)

 

 

Thanks, your solution also worked, I tried to add in for it to be able to handle 0 input along side blanks but couldn't get it working. Thanks again for replying

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,346)