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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ViorelCa
Helper I
Helper I

Variable error powerpivot

Dear Colleagues,

 

When I calculate this single expression it is ok:

 

LastActualDate:=LASTNONBLANK(Clasa6si7[FECHA],1)

 

But when I wrap it inside a variable, I get the error "The syntax for LastActualDate is incorrect"

 

Am I doing something wrong? (Excel2013 Powerpivot)

 

BudgetYTD:=

 

VAR

LastActualDate:=LASTNONBLANK(Clasa6si7[FECHA],1)

RETURN

 

CALCULATE(
SUM(AppendOGOAll[P2017cost]),
FILTER(
ALL(CalendarTable[Calendar Date]),
CalendarTable[Calendar Date] <= LastActualDate
))

1 ACCEPTED SOLUTION
Datatouille
Solution Sage
Solution Sage

Hi @ViorelCa

 

1. DAX variables are only available from the 2015 edition of DAX so: PowerPivot for Excel 2016, Power BI Desktop & SSAS 2016. Thus, not in PowerPivot for Excel 2013.

2. In any of the three softwares mentioned above, you should remove the " " in the variable definition and also remove the 'filter' function (which is useless thanks to the variable).

This one would work:

 

BudgetYTD = VAR LastActualDate=LASTNONBLANK(Clasa6si7[FECHA],1) RETURN
Calculate( SUM(AppendOGOAll[P2017cost]) , CalendarTable[Calendar Date] <= LastActualDate)

 

 

 

View solution in original post

2 REPLIES 2
Datatouille
Solution Sage
Solution Sage

Hi @ViorelCa

 

1. DAX variables are only available from the 2015 edition of DAX so: PowerPivot for Excel 2016, Power BI Desktop & SSAS 2016. Thus, not in PowerPivot for Excel 2013.

2. In any of the three softwares mentioned above, you should remove the " " in the variable definition and also remove the 'filter' function (which is useless thanks to the variable).

This one would work:

 

BudgetYTD = VAR LastActualDate=LASTNONBLANK(Clasa6si7[FECHA],1) RETURN
Calculate( SUM(AppendOGOAll[P2017cost]) , CalendarTable[Calendar Date] <= LastActualDate)

 

 

 

Dear Tristan,

Thanks a lot for your quick reply!
Now it is clear!
How confuzing are these differences in the Microsoft BI microsystem!

Kind regards,
Viorel

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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