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
Maybrick1046
Frequent Visitor

The Syntax for... is incorrect

4PBIGroup.jpg

I cannot for the life of me determine what is wrong with this statement.  Any help appreciated

5 REPLIES 5
ValtteriN
Super User
Super User

Hi,

var needs return in the end and then you can refer to the variable. 

E.g. measure = var _a = 1
return 
_a

So add: "return" and "data" and you are good

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Not working with the return
4PBIGroup1.jpg

Hi, At a quick glance it seems you are missing closing ')' from your data variable.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




There are many variables, and if you notice, in the data table itself it's not finding the field name.  Can  I hire you to help me get this right?

Hi,

The reference is greyd out if the rest of the table syntax is not working. E.g. Here I tested some similar syntax in my machine:

Measure 29 = var data =
FILTER(
SELECTCOLUMNS(ALLSELECTED('Table (15)'[Column1]),"x",'Table (15)'[Column1],"y",1),

    NOT(ISBLANK([x])) && NOT(ISBLANK([y]))
    )


var x_sum = SUMX(data,[x])
var x2 = SUMX(data,[x]^2)
var xy= SUMX(data,[x])
var row_count = COUNTROWS(data)

return 1


This works without errors:
ValtteriN_0-1674049326698.png

 







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.