The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Solved! Go to Solution.
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.
While replacing blanks with zero if output of the measure will be numeric. No syntax or typo error in the dax.
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.
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.
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.
User | Count |
---|---|
80 | |
73 | |
39 | |
30 | |
28 |
User | Count |
---|---|
107 | |
99 | |
55 | |
49 | |
46 |