Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

IF statement w/ expression as value_if_true

I'm trying to wrap a DIVIDE in an IF statement to handle a condition where the DIVIDE returns BLANK(). I want to use an expression for the value_if_true. How can I do this?   Here is my code which ...
  • Anonymous's avatar
    Anonymous
    7 years ago

    ah, my bad, a missing return

     

    Cost per Opportunities Closed Won =
    VAR r =
        DIVIDE (
            SUM ( 'Nexus-Campaigns'[Actual Campaign Cost] ),
            [Opportunities Closed Won]
        )
    RETURN
        IF ( ISBLANK ( r ), SUM ( 'Nexus-Campaigns'[Actual Campaign Cost] ), r )