Forum Discussion

o59393's avatar
o59393
Post Prodigy
6 years ago
Solved

Calculate function not filtering launched projects

Hi all !   I created a dax function (product kpi) to calculate the % of how good we are at launching projects. The rule is simple   1-(Real days-Theorical Days)/Theorical Days   It calcualtes i...
  • TomMartens's avatar
    6 years ago

    Hey o59393 ,

     

    the reason why there is a percentage, is because the formula is reduced to this, when the status does not equal "launched":

     

    1 - NULL

     

    this leads to a percentage of 100% as NULL is coerced to 0 (zero)

     

    I guess this provides what you are looking for:

     

    Product KPI = 
    var _percentage = (CALCULATE(SUM(Table_query__13[Tech_COMM_Days_Real]),Table_query__13[Status]="Launched")-CALCULATE(SUM(Table_query__13[Tech_COMM_Days_Gantt]),Table_query__13[Status]="Launched"))/CALCULATE(SUM(Table_query__13[Tech_COMM_Days_Gantt]),ABS(Table_query__13[Status]="Launched"))
    return
    IF( _percentage == BLANK()
        , BLANK()
        , 1 - _percentage
    )

     

    Here the result of the "calculation" is stored to the variable "_percentage".

    Then using the strict operator == (indeed 2 equal signs) allows to check if the value of the variable is BLANK() meaning NULL.

    Using this formula, the matrix visual just contains this:

    Hopefully this is what you are looking for.

     

    Regards,

    Tom