- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How DAX Execute VAR/ RETURN
Hi!
I'm just curious how does DAX execute VAR/ RETURN lines? Will it
- execute/ evaluate all the VARs first then RETURN values based on the VARs? or
- will it run RETURN first then check which VARs are necessary then evaluate only those VARs?
For example I have a measure with the following lines below. Since I did not use VAR2 in my RETURN statement, will it still evaluate VAR2?
Measure = VAR1 = SUM(Table[Column1]) VAR2 = SUM(Table[Column2]) VAR3 = SUM(Table[Column3]) RETURN DIVIDE(VAR1, VAR3)
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Anonymous
The compiler will check for potential errors but at execution time the variable will only be evaluated if it's invoked in the RETURN part. For instance:
Measure = VAR VAR1 = SUM(Table1[Column1]) VAR VAR2 = 3/VALUES(Table1[Column1]) VAR VAR3 = SUM(Table1[Column1]) RETURN VAR1
will NOT generate an error even though at VAR2 we are dividing by a column but this will:
Measure = VAR VAR1 = SUM(Table1[Column1]) VAR VAR2 = 3/VALUES(Table1[Column1]) VAR VAR3 = SUM(Table1[Column1]) RETURN VAR2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Anonymous
The compiler will check for potential errors but at execution time the variable will only be evaluated if it's invoked in the RETURN part. For instance:
Measure = VAR VAR1 = SUM(Table1[Column1]) VAR VAR2 = 3/VALUES(Table1[Column1]) VAR VAR3 = SUM(Table1[Column1]) RETURN VAR1
will NOT generate an error even though at VAR2 we are dividing by a column but this will:
Measure = VAR VAR1 = SUM(Table1[Column1]) VAR VAR2 = 3/VALUES(Table1[Column1]) VAR VAR3 = SUM(Table1[Column1]) RETURN VAR2

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
05-22-2024 02:38 AM | |||
09-17-2024 07:03 AM | |||
Anonymous
| 11-11-2021 10:51 PM | ||
08-30-2024 11:38 AM | |||
09-04-2024 09:23 AM |
User | Count |
---|---|
96 | |
87 | |
83 | |
52 | |
51 |