Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

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

  • v-yuta-msft's avatar
    v-yuta-msft
    Icon for Community Support rankCommunity 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.