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
Anonymous
Not applicable

VAR stopped working after update

I had numerous measures using the VAR keyword in Power BI that worked fine until the last update in November. I found that I could fix the issue by just altering the syntax just a little bit (I think i added a space, something not intuitive... took me hours to figure it out). Any ways, I'm using the same logic for a new measure in Power BI. once again, it's now not working. This is the same logic I've used on previous measures using VAR. Can someone please help me? This is incredibly frustrating. 

 

The syntax is below. The error I get is "The syntax for 'RETURN' is incorrect" followed by a long string of text. Below is the measure formula I am using. I am trying to use the VAR MaxDate to filter my selection of data. 

 

UL % Curr Mo = VAR MaxDate = MAX('Loss Cat Data'[PE FC MoYr] RETURN CALCULATE(SUM('Loss Cat Data'[Potential]), 'Loss Cat Name'[Loss Type] = "U", 'Loss Cat Data'[PE FC MoYr] = DATE(YEAR(MaxDate), MONTH(MaxDate), DAY(MaxDate))) / CALCULATE(SUM('Loss Cat Data'[Potential]))

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous

 

On my first look I saw a missing ) in VAR highlighted in RED below

 

UL % Curr Mo = VAR MaxDate = MAX('Loss Cat Data'[PE FC MoYr]) RETURN CALCULATE(SUM('Loss Cat Data'[Potential]), 'Loss Cat Name'[Loss Type] = "U", 'Loss Cat Data'[PE FC MoYr] = DATE(YEAR(MaxDate), MONTH(MaxDate), DAY(MaxDate))) / CALCULATE(SUM('Loss Cat Data'[Potential]))


Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous

 

On my first look I saw a missing ) in VAR highlighted in RED below

 

UL % Curr Mo = VAR MaxDate = MAX('Loss Cat Data'[PE FC MoYr]) RETURN CALCULATE(SUM('Loss Cat Data'[Potential]), 'Loss Cat Name'[Loss Type] = "U", 'Loss Cat Data'[PE FC MoYr] = DATE(YEAR(MaxDate), MONTH(MaxDate), DAY(MaxDate))) / CALCULATE(SUM('Loss Cat Data'[Potential]))


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Well now I feel embarassed - that fixed it. Thanks !!

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.