cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

DAX IF Statement

I am new to writing DAX and trying to write the below IF statement:

 

Forecast/Actual= If TableX(actual amount) has a value, use TableX(actual amount) value. If TableX(actual amount) has no value, use Table Y(forecast amount)

 

No value meaning blank or 0.

 

Any help would be greatly appreciated! Thanks in advance

 

 

1 REPLY 1
kentyler
Solution Sage
Solution Sage

DAX offers the ISBLANK() function that you can use to solve part of your problem.

VAR replace = OR(IF( ISBLANK(TableX[actual amount]) ,  TableX[actual amount] =0)

RETURN IF(replace,tabley[forecast amount],tablex[actual amount])

 

this separates the test for whether or not you want to replace the value by using the OR function, if either of the arguments to OR is true it returns true.

If replace = true then you return the forecast, otherwise the actual





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.

Top Solution Authors
Top Kudoed Authors