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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.