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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
AC23VM
Helper II
Helper II

The syntax for 'RETURN' is incorrect

Hi there.  I've tried to write this formula 500 different ways.  I've tried DAX Formatter (which says this is fine) and even tried AI suggestions, but no matter what I get the same syntax error.

VAR __CountActualHarm =
COUNT ( 'Outcomes Testing Data'[Grading - Actual Harm] )
RETURN
IF ( ISBLANK ( __CountActualHarm ), 0, __CountActualHarm )

I initially followed a YouTube tutorial for replacing blanks with zeroes to the letter, but again got this error.  For context, the grading is a conditional column that's just if X = Actual Harm then 1 else null.  

1 ACCEPTED SOLUTION
danextian
Super User
Super User

I don't see anything wrong with your formula. But the RETURN clause can simplified as _CountActualHarm + 0.

Now this may not return 0 if for example you are trying to return it for October but there's no October  row 5 in your table and you're using the date column  from the same table. Simply put, you cant assign a value to a row that doesn't exist, 0 or not.  This why it is important to use  separate date/calendar table with a complete set of dates whether they exist in your fact table or not.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
skparavind_1994
Frequent Visitor

While replacing blanks with zero if output of the measure will be numeric. No syntax or typo error in the dax. 

danextian
Super User
Super User

I don't see anything wrong with your formula. But the RETURN clause can simplified as _CountActualHarm + 0.

Now this may not return 0 if for example you are trying to return it for October but there's no October  row 5 in your table and you're using the date column  from the same table. Simply put, you cant assign a value to a row that doesn't exist, 0 or not.  This why it is important to use  separate date/calendar table with a complete set of dates whether they exist in your fact table or not.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
AC23VM
Helper II
Helper II

Ah right.  I don't know how to do that haha.  I want a table with a column that shows amounts of 'Actual Harm' values.  So, for instance, if there were 5 in October and none in November, my current table says "Oct - 5, Nov - Blank" because the contitional column is 1 and null.  I'm not sure how to write a COUNTROWS and FILTER where it's differentiating the 1 and null rows, and then turning the nulls into zeroes.

In the below example, I am using a date column from a separate date dimension. Those with sum of sales are the dates present in the fact table but since i am using a separate dates table, I can assign a value to its rows even if they don't exist in the fact table.

danextian_0-1734522531555.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
grazitti_sapna
Super User
Super User

Hi @AC23VM ,

Your DAX formula syntax looks correct, and based on what you shared, the error likely originates elsewhere in the data model or specific column

1. Verify Column Name : Ensure that the column name is correct and matches exactly as it appears in the data model

2. Replace COUNT with SUM or SUMX for Numeric Columns
If Grading - Actual Harm contains 1 and BLANK values:

COUNT counts all non-blank rows.
If you want to treat 1 as the actual value and replace blanks with 0, you may need to aggregate it differently.

3.Use COUNTROWS with FILTER if conditions are involved.

 

I hope the provided solution works for you

If I have resolved your question, please consider marking my post as a solution. Thank you!
A kudos is always appreciated—it helps acknowledge the effort and keeps the community thriving.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.