Forum Discussion

o59393's avatar
o59393
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

IF statement as measure

Hi all   I am doing an if measure instead of a calculated column. The dax is pretty simple, if the column type contains the word ingredients do one sum, if the same column type contains the word...
  • PaulDBrown's avatar
    PaulDBrown
    6 years ago

    o59393 

    Sorry, I meant try the substitution in your orginal measure, (excluding the && FIRSTNONBLANK part...)

  • v-lili6-msft's avatar
    v-lili6-msft
    6 years ago

    hi  o59393 

    The problem is that the data type of these columns 'Suppliers Compliance'[Audit Score (2] , 'Suppliers Compliance'[CAP Score (5_x] ,'Suppliers Compliance'[QF Score (20_x] , 'Suppliers Compliance'[Score Threats _x0028] , 'Suppliers Compliance'[Score Analysis _x002] are Text.

    Then just change the data type of these columns to Number and use this formula

    Q/FS Total DAX = 
    
    var _package = (SUM('Suppliers Compliance'[Audit Score (2]) + SUM('Suppliers Compliance'[CAP Score (5_x]) + SUM('Suppliers Compliance'[QF Score (20_x]) + SUM('Suppliers Compliance'[Score Threats _x0028]) + SUM('Suppliers Compliance'[Score Analysis _x002]) ) /70
    
    var _ingredients = (SUM('Suppliers Compliance'[Audit Score (2]) + SUM('Suppliers Compliance'[CAP Score (5_x]) + SUM('Suppliers Compliance'[QF Score (20_x]) + SUM('Suppliers Compliance'[Score Threats _x0028]) ) /70
    
    return
    
    IF( SELECTEDVALUE( 'Suppliers Compliance'[Type] )   = "Ingredients", _ingredients  , _package)
    

     

    Result:

    Regards,

    Lin