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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
obriaincian
Resolver I
Resolver I

Power BI - Calculated Column, Error with variables

 

Can someone please tell me why the second variable is erroring:

 

 

var _max = maxx(filter(Table, [Product] =earlier([Product]) && [Date] <earlier([Date)),[Date])
var _exp = maxx(filter(Table, [Product] =earlier([Product]) && [Date] =_max),[Expiry Date])

return
Switch ( true(),
isblank([Expiry Date]) , "No Expiry Date",
[Expiry Date] =_exp , "No Change",
_exp>EOMONTH([Expiry Date],0),"> 1 month change",
_exp<EOMONTH([Expiry Date],0),"< 1 month change"
)

 

1 ACCEPTED SOLUTION
Tahreem24
Super User
Super User

@obriaincian , I can see square bracket is missing in earlier of Date:

var _max = maxx(filter(Table, [Product] =earlier([Product]) && [Date] <earlier([Date])),[Date])

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

4 REPLIES 4
Tahreem24
Super User
Super User

@obriaincian , I can see square bracket is missing in earlier of Date:

var _max = maxx(filter(Table, [Product] =earlier([Product]) && [Date] <earlier([Date])),[Date])

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Tahreem24
Super User
Super User

@obriaincian  What error are you getting?

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

@Tahreem24 , it's saying the syntax for var is incorrect

@obriaincian Refer my another reply regarding missing square bracket of earlier([Date]) in first var.

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.