Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Create DAX measure from Excel Formula

Hello-

 

I am looking to re-create the below excel formula using DAX in Power BI.

 

 

When I do it in Power BI, I get column results:

23

17

18

0

0

0

 

The end column result should be the yellow column (like the screenshot above):

23

17

18

9.666

9.666

9.666

 

I tried DAX Formula --> 

Column = CALCULATE(IF(Table1[2020 Forecast_] = 0, AVERAGE(Table1[2020 Forecast]), [2020 Forecast_]))
 

 But it doesn't work 😞

  • Hi Anonymous 

    try column

    Column = if([2020 Forecast_]=0;average(Table1[2020 Forecast_]);[2020 Forecast_])

    if you do not need a row context

    and column

    Column = if([2020 Forecast_]=0;calculate(average(Table1[2020 Forecast_]);ALL(Table1));[2020 Forecast_])

    if you do need

     

    do not hesitate to give a kudo to useful posts and mark solutions as solution

2 Replies

  • az38's avatar
    az38
    Community Champion

    Hi Anonymous 

    try column

    Column = if([2020 Forecast_]=0;average(Table1[2020 Forecast_]);[2020 Forecast_])

    if you do not need a row context

    and column

    Column = if([2020 Forecast_]=0;calculate(average(Table1[2020 Forecast_]);ALL(Table1));[2020 Forecast_])

    if you do need

     

    do not hesitate to give a kudo to useful posts and mark solutions as solution

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks az38. I had to change the ; to a , but other than that, it worked well. Thank you!