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
Anonymous
Not applicable

VAR RETURN syntax not working

Hi guys,

can anyone explain why the first DAX formula gives a correct result:

AVERAGE =
CALCULATE(AVERAGE('Tab 3'[Measure]);
CALCULATETABLE(
TREATAS(VALUES('Tab 2'[K_TWO]);'Tab 3'[K_TWO])
;
TREATAS(CALCULATETABLE(VALUES('Tab 1'[K_ONE]);'Tab 1'[Type]=0);'Tab 2'[K_ONE])
))

while the second one, with variables:

AVERAGE (VAR) =
VAR T1 = TREATAS(VALUES('Tab 2'[K_TWO]);'Tab 3'[K_TWO])
VAR T2 = TREATAS(CALCULATETABLE(VALUES('Tab 1'[K_ONE]);'Tab 1'[Type]=0);'Tab 2'[K_ONE])
RETURN
CALCULATE(AVERAGE('Tab 3'[Measure]);
CALCULATETABLE(T1;T2))

does not?
Thanks!

1 REPLY 1
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

Could you please share some sample data and clarify more details?

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.