Skip to main content

#TipOffContest 

Hi Community,

 

This tip is so simple but useful, it's a formula to give format like this XXX.XXX.XXX to formulate text field, in this case can't be a formula field number because after the number we need include and image.

 

Use case: We have a number custom field (OriginField__C) this field will be hidden and we need to show on page a field with number, currency symbol € (in this case) and image depends on a number (Green circle) or negative number (red field).

 

Solution: Create a formula text field, with this value:

 

CASE(LEN(TEXT(OriginField__c)),

1, TEXT(OriginField__c),

2, TEXT(OriginField__c),

3, TEXT(OriginField__c),

4, LEFT(TEXT(OriginField__c), 1) & "." & RIGHT(TEXT(OriginField__c), 3),

5, LEFT(TEXT(OriginField__c), 2) & "." & RIGHT(TEXT(OriginField__c), 3),

6, LEFT(TEXT(OriginField__c), 3) & "." & RIGHT(TEXT(OriginField__c), 3),

7, LEFT(TEXT(OriginField__c), 1) & "." & MID(TEXT(OriginField__c), 2,3) & "." & RIGHT(TEXT(OriginField__c), 3),

8, LEFT(TEXT(OriginField__c), 2) & "." & MID(TEXT(OriginField__c), 3,3) & "." & RIGHT(TEXT(OriginField__c), 3),

9, LEFT(TEXT(OriginField__c), 3) & "." & MID(TEXT(OriginField__c), 4,3) & "." & RIGHT(TEXT(OriginField__c), 3),

10, LEFT(TEXT(OriginField__c), 1) & "." & MID(TEXT(OriginField__c), 2,3) & "." & MID(TEXT(OriginField__c), 5, 3) & "." & RIGHT(TEXT(OriginField__c), 3),

11, LEFT(TEXT(OriginField__c), 2) & "." & MID(TEXT(OriginField__c), 3,3) & "." & MID(TEXT(OriginField__c), 6, 3) & "." & RIGHT(TEXT(OriginField__c), 3),

12, LEFT(TEXT(OriginField__c), 3) & "." & MID(TEXT(OriginField__c), 4,3) & "." & MID(TEXT(OriginField__c), 7, 3) & "." & RIGHT(TEXT(OriginField__c), 3),

null)& "€ "& IF(OriginField__c>=0, IMAGE("img root", "Positivo") , IMAGE("img root", "Negativo")) 

3 条评论
0/9000