Forum Discussion

simuruge's avatar
simuruge
Regular Visitor
6 years ago
Solved

How do I create a measure that returns two different values based on condition

Hi,   I am trying to trplicate a formula in Tableau like, ([Plan $] + IIF([Version]=[Version Toggle],[Perf $],0))   [Version] is a column in a table [Version Toggle] is a dynamic value where the...
  • v-xuding-msft's avatar
    6 years ago

    Hi simuruge 

     

    I create a simple sample. Please try the formulas to check if it is what you want.

     

    • For this formula, if we don't select any values in slicer, it will return 0 by default.
    Measure =
    VAR Selected_Version =
        SELECTEDVALUE ( 'Table 1'[Version] )
    VAR a =
        SUMX (
            'Table',
            'Table'[Plan]
                + IF ( 'Table'[Version] = Selected_Version, SUM ( 'Table'[Perf] ), 0 )
        )
    RETURN
        a
    
    • If you want to show other data without selecting, you could try this:
    Measure 2 =
    VAR Selected_Version =
        SELECTEDVALUE ( 'Table 1'[Version] )
    VAR a =
        SUMX (
            'Table',
            'Table'[Plan]
                + IF ( 'Table'[Version] = Selected_Version, SUM ( 'Table'[Perf] ), 0 )
        )
    RETURN
        IF ( ISFILTERED ( 'Table 1'[Version] ), a, "No Filter" )
    

     

    For more details, please download my sample to have a try.