-1

I got this formula and I got stuck trying to make it work. How do I get the result to be compatible with a currency field? Any help would be greatly appreciated!

The error: Formula result is data type (Boolean), incompatible with expected data type (Currency).

Here is the formula:

IF(
    VL__Transaction_Type__c = 'Dividend',
    VL__Transaction_Type__c =  TEXT(Dividend__r.Amount__c) ,
    IF(
        VL__Transaction_Type__c = 'Debt',
        VL__Transaction_Type__c =  TEXT(Debt__r.Principal__c ) ,
        IF(
            VL__Transaction_Type__c = 'Valuation',
            VL__Transaction_Type__c = TEXT(Valuation__r.Fair_Market_Value__c),
            IF(
                VL__Transaction_Type__c = 'Share Activity',
                VL__Transaction_Type__c = TEXT(Share_Activity__r.Capital_Committed__c),
                IF(
                    VL__Transaction_Type__c = 'Repayment',
                    VL__Transaction_Type__c = TEXT(Repayment__r.Repaid_Principal__c + Repayment__r.Repaid_Interest__c), 
                    ISBLANK(null) 
                )
            )
        )
    )
)

Screenshot

1
  • 4
    Please edit your question to include the formula and error as text rather than as an image. Images are poor for accessibility, and making suggestions about how to change your formula would require someone to manually type out the entire formula.
    – Derek F
    Commented May 12, 2022 at 14:11

2 Answers 2

1

A few things to note here:

  • When you are making multiple comparisons against a single field, you should consider using CASE() to save yourself a potentially significant amount of typing
  • A formula field, in and of itself, cannot set the value of another field (you'd need a Field Update action as part of a workflow rule, process builder, or flow to do that)
  • You need to ensure that all possible results from your formula match the type of your formula field

The second point means that all of the THEN parts of the IF-THEN-ELSE (which currently look like VL__Transaction_Type__c = TEXT(Valuation__r.Fair_Market_Value__c)) should be removed. You can't set a value here, and it doesn't make much sense to update VL__Transaction_Type__c in this context anyway. You're looking to simply fetch a value from a field (which depends on the value of VL__Transaction_Type__c).

The third point means that instead of TEXT(Valuation__r.Fair_Market_Value__c), which turns numbers and such into strings, they should be replaced with simply Valuation__r.Fair_Market_Value__c. I'm assuming that each of the fields you're using here are Currency fields (or at the very least, numbers).

Putting that all together would give you something like this

/* CASE() can take as many arguments as you can throw at it */
/* The first is always the variable value you want to match with */
/* Each pair of arguments after that is the target value to match */
/*   followed by the value to return */
/* The final argument is the default value to return if no matches */
/*   are found, and it is required */
CASE(VL__Transaction_Type__c,
    'Dividend', Dividend__r.Amount__c,
    'Debt', Debt__r.Principal__c, 
    /* Replace the remaining 0s with your desired fields */
    /* except for the final 0, which is the default value */
    'Valuation', 0,
    'Share Activity', 0,
    'Repayment', 0,
    0
)
1
  • Thanks Derek! I initially went with case but I did not include the zero as default at the end. Still new to this and became unsure. Appreciate the time you put in to help me out. =)
    – M-Audio
    Commented May 12, 2022 at 20:09
1

Remove the last IsBlank(null) instead, just make it null. By saying IsBlank, you are returning true (as null is always blank) and hence the complain from the compiler.

3
  • I tried making it null, but I still get the same error.
    – M-Audio
    Commented May 12, 2022 at 15:41
  • You should make formula treat blank as zeros. That is the setting in formula field. You could also return 0 instead of null.
    – metasync
    Commented May 12, 2022 at 16:14
  • Hey Metasync, I tried your suggestion and with treating blank as zero's, it still gave me the error. I appreciate you taking the time to respond tho =)
    – M-Audio
    Commented May 12, 2022 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .