Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Help: How to calculate Rate?

I am working with Success Rate:

  • cntd_suc_rate_p = format([cntd_suc]/[cntd],"0.0%")
  • cntd_suc = CALCULATE([cntd],'f_table'[project_status]="Successful")
  • cntd = DISTINCTCOUNT('f_table'[proj_id])

 

When "Successful" is selected (in [project_status]), the Rate is fine, e.g.

 

But, if "Successful" is not selected, then get anomalies for the Rate values, e.g.

or

 

I think this problem is casued by the DAX expresssion that only works with "Successful" no matter it is selected or not:

  • cntd_suc = CALCULATE([cntd],'f_table'[project_status]="Successful")

 

How should I change the DAX expression for the following logic?

  • Success Rate = (# of successful projects) / (# of projects)
  • If you unselect 'Succesfull'  as filter, what number do you want to see then? Because if you uncheck 'Succesfull', I would expect you want cntd_suc to be 0. 

    Change your cntd_suc into this:

     

    cntd_suc = CALCULATE([cntd],FILTER(f_table; 'f_table'[project_status]="Successful"))

     

    This returns the count of succesfull projects based on applicable filters. The applicable filters in your example are:

    1. The slicer and its values, and;

    2. The context of the visual, so for example the Year in your example.

     

    Kind regards

    Djerro123

    -------------------------------

    If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

    Kudo's are welcome 🙂

1 Reply

  • JarroVGIT's avatar
    JarroVGIT
    Resident Rockstar

    If you unselect 'Succesfull'  as filter, what number do you want to see then? Because if you uncheck 'Succesfull', I would expect you want cntd_suc to be 0. 

    Change your cntd_suc into this:

     

    cntd_suc = CALCULATE([cntd],FILTER(f_table; 'f_table'[project_status]="Successful"))

     

    This returns the count of succesfull projects based on applicable filters. The applicable filters in your example are:

    1. The slicer and its values, and;

    2. The context of the visual, so for example the Year in your example.

     

    Kind regards

    Djerro123

    -------------------------------

    If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

    Kudo's are welcome 🙂