cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Frequent Visitor

Re: DAX - Confused over use of VAR

@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
Highlighted
Super User IV
Super User IV

Re: DAX - Confused over use of VAR

Try like

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


Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Helper I
Helper I

Re: DAX - Confused over use of VAR

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).

Highlighted
Frequent Visitor

Re: DAX - Confused over use of VAR

@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

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors