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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BlueSky
Helper I
Helper I

DAX - Confused over use of VAR

Hi,

 

Another newbie question, I'm confused over the use of variables.

In the first statement below, I'm able to define, myValue = [Value]  (created by GENERATESERIES () and use this in the second argument for GENERATE().

However in the second statement, I'm trying to do the same thing with ADDCOLUMNS() yet it produces an error ( 'Parameter is not the correct Type, cannot find [Value]'

 

Can someone help explain?

 

NewTable =
GENERATE(
GENERATESERIES ( 0, 10, 0.5 )
, VAR myValue = [Value]
return
row("Test",myValue)
)


NewTable =
ADDCOLUMNS(
GENERATESERIES ( 0, 10, 0.5 )
, VAR myValue = [Value]
return
"Test",myValue
)

 

 

 



1 ACCEPTED SOLUTION

@BlueSky 

 

You must use the variable inside the expression where value is evaluated

so this should work

 

NewTable = 
ADDCOLUMNS(
GENERATESERIES ( 0, 10, 0.5 )
, 
"Test",VAR myValue = [Value]
return myValue
)

 

 

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

Try like

NewTable = 
ADDCOLUMNS(
GENERATESERIES ( 0, 10, 0.5 )
, 
"Test", [Value]
)

Thanks for the reply but you've not answered the question, I'm trying to understand why the variable produces an error in the second senario, when it's usage is the same as the first (where there is no error).

@BlueSky 

 

You must use the variable inside the expression where value is evaluated

so this should work

 

NewTable = 
ADDCOLUMNS(
GENERATESERIES ( 0, 10, 0.5 )
, 
"Test",VAR myValue = [Value]
return myValue
)

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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