Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dcunningham27
Helper I
Helper I

Create DAX measure from Excel Formula

Hello-

 

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

 

save.png

 

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 😞

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @dcunningham27 

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


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

View solution in original post

2 REPLIES 2
az38
Community Champion
Community Champion

Hi @dcunningham27 

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


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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors