Forum Discussion
Power BI - The syntax for ')' is incorrect
Hello, I am trying to enter a formula in DAX to calculate the number of people receiving care support in a particular quarter but keeping getting a syntax error "The syntax for ')' is incorrect" . I have 2 tables:
Data - contains records of people including unique ID and start and end dates of support
Quarters - contains name of Quarter eg 2025/26 Q3, and start and end date of quarter.
The formula is:
Nos Supported = VAR lastqtrdate = MAX(Quarters[Qtr End Date])
var firstqtrdate = min(Quarters[Qtr Start Date])
var result = CALCULATE(COUNTROWS(Data),Data[Start Date]<=lastqtrdate,Data[End Date]>=firstqtrdate)
I'm basically trying to adapt this guy's formula on https://exceleratorbi.com.au/how-many-employees-by-period/ . Has anyone any thoughts?
Thank you
Missing RETURN statement and it is needed when you use VAR (only).
add after the last line:
RETURN
result
7 Replies
- awalker2009Frequent Visitor
Thanks. I've taken that on board and the formula is working now.
- GeraldGEmerick
Memorable Member
awalker2009 Those can't be the full formulas as you are using VAR statements without a RETURN statement.
- Zanqueta
Super User
Hello awalker2009,
The error message "The syntax for ')' is incorrect" in your DAX measure is caused by the way filters are being applied within the CALCULATE function. In DAX, filters inside CALCULATE must be valid Boolean expressions or table filters. Expressions such as Data[Start Date] <= lastqtrdate must be wrapped in a FILTER function to be valid.Please, try it:
Nos Supported = VAR lastqtrdate = MAX(Quarters[Qtr End Date]) VAR firstqtrdate = MIN(Quarters[Qtr Start Date]) RETURN CALCULATE( COUNTROWS(Data), FILTER( Data, Data[Start Date] <= lastqtrdate && Data[End Date] >= firstqtrdate ) )✅ If this response resolved your issue, please mark it as correct to assist other members of the community.
- sevenhills
Super User
Missing RETURN statement and it is needed when you use VAR (only).
- danextian
Super User
add after the last line:
RETURN
result
- AnonymousNot applicable
Hi awalker2009
Thank you for reaching out to the Microsoft Fabric Forum Community.
@danextian sevenhills GeraldGEmerick Zanqueta Thank you so much for your inputs.
I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.
- AnonymousNot applicable
Hi awalker2009
Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.