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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Hila_DG_TMX
Frequent Visitor

RETURN in the middle of a DAX statement

Hi, 

 

I have a complex DAX statment to calculate a column (yes, I know, don't get me started). 

It works. 

It has several calculations, all organised nicely using VAR statements. 

The issue is as follows:

I want the code to return a specific value if a certain condition is met in the 1st go, and then not run through the extra caculations. 

So, instead of:

0.1 My Col = 

 _VAR _V1 = calc
 _VAR _V2 = calc
 _VAR _V3 = calc
VAR _RET = IF (Table[column], 8, _v1 + v2 +v3)
RETURN _RET

Which means I would run all 3 calcs, 

I want to write something like: 

0.1 My Col = 
IF (Table[column], 
   RETURN 8, 
   _VAR _V1 = calc
   _VAR _V2 = calc
   _VAR _V3 = calc
   RETURN _v1 + v2 +v3
)

I don't get it to work. 

 

Is it even possible? Thanks!

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Hila_DG_TMX 

This should be the correct syntax:

0.1 My Col =
IF (
    Table[column],
    8,
    VAR _V1 = calc
    VAR _V2 = calc
    VAR _V3 = calc
    RETURN
        _V1 + _V2 + _V3
)

The three variables should only be evaluated when the condition within IF is false.

 

Does this work as expected for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

1 REPLY 1
OwenAuger
Super User
Super User

Hi @Hila_DG_TMX 

This should be the correct syntax:

0.1 My Col =
IF (
    Table[column],
    8,
    VAR _V1 = calc
    VAR _V2 = calc
    VAR _V3 = calc
    RETURN
        _V1 + _V2 + _V3
)

The three variables should only be evaluated when the condition within IF is false.

 

Does this work as expected for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.