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
George1973
Helper V
Helper V

Goto Function in DAX

Hi,

I just wonder, if there any replacement of "GoTo" function/Operator in DAX, in order to to able to "jump" to the specific line in a DAX coding?

Thanks in advance,

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @George1973 ,

 

In DAX formula, no directly support for “GoTo” function. But if you would like to execute different dax formula segment for different condition, you need do it with IF or Switch function. For more details about these two functions, you may refer to IF function (DAX) - DAX | Microsoft Docs and SWITCH function (DAX) - DAX | Microsoft Docs.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

6 REPLIES 6
v-cazheng-msft
Community Support
Community Support

Hi @George1973 ,

 

In DAX formula, no directly support for “GoTo” function. But if you would like to execute different dax formula segment for different condition, you need do it with IF or Switch function. For more details about these two functions, you may refer to IF function (DAX) - DAX | Microsoft Docs and SWITCH function (DAX) - DAX | Microsoft Docs.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Hi @v-cazheng-msft 
Hi @daXtreme 

 

I do undesrand your suggestions. Thanks a lot.
My point, regarind 'Goto', was because of having more than 1500 lines in Measure Code and just to skip some parts from top to down.

I'm fine with IF and SWITCH functions. Just what I want, is to "Skip" some parts in order to reduce calculation everall speed.

1500 lines of DAX code for a measure? With all respect, if this is the case, it most likely means your model should be seriously re-thought. In good models measures are simple. In bad models... well, you get the gist. If I saw a model, where a measure is 1500 lines long, I would immediately replace the model together with the author.

Dear @daXtreme 
Dear @v-cazheng-msft 

:))))) With all respect.. LOL.. Yes, yes.. the measure is so long (1300-1500 lines).
The task itself is too complex. Imagine that you have to:

1. Calculate "Smoothed" data of the repvious 24 months based on some statistical approach. Each month seperately and store them into seperate measures/variables
2. Seasonality/Sporadic status based on the "smoothed" data
3. Calculat forecast for upcomming 12 month with 9(!) independent scenarios and taking into accouont that for each product the scenario could be different.
4. Store each forecast for upcomming 12 months into 12 seperate measures/variables
5. Once the forecast is been calculated, calculate Supply order
---- I have done it all----- !!!! :))))) With one measure!
Because, If I had tried to keep the previous variables into the the seperated measures and refer to the [Measure] in the main, ultimate masure, it would take more than 10 minutes to calculate the result.. Yes, 10 min!

Now, with one measure, keeping all those variables in one measure saves a huge amount of time, reducing the total calculation time to 1 min (maximum).

The next step, what I want to develop, is the one, what I have annouced here.. Having +12 month rolling forecast + budget+Supply..  BUT, here is the problem.. ThE TIME.. More calculation I have, More the time increase :)) 

Hi @George1973 ,

 

I think you need do that with some conditions in your calculations. Just like the formula in this post: Solved: Skip rows with condition using DAX - Microsoft Power BI Community.

Or you could add an index column to your table and select rows you needed by these numbers. Or you could consider the TOPN DAX function, it will return the top N rows of the specified table by the result of the specific expression.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

daXtreme
Solution Sage
Solution Sage

DAX does not need a GOTO construct. It's a functional language.

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.