Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Solved! Go to Solution.
The syntax error you’re encountering is due to how escape characters are being handled within the FORMAT function’s format string in DAX.
The Problem in this expression: FORMAT((Actual - FC) * 10000, "0\"bps\";\"(\"0\")bps\"")
You're attempting to use escaped double quotes \" inside a DAX string, but DAX doesn't use backslashes (\) to escape quotes. Instead, DAX escapes double quotes by doubling them, like this: "".
You should replace all \" with "". Corrected version of your DAX expression:
% Variance Actual vs FC = VAR MetricType = SELECTEDVALUE('Results (2)'[Period]) VAR Actual = SELECTEDVALUE('Results (2)'[MTD Actual]) VAR FC = SELECTEDVALUE('Results (2)'[MTD FC]) RETURN IF( MetricType = "Percentage", FORMAT((Actual - FC) * 10000, "0""bps"";(""0"")bps"), FORMAT(Actual - FC, "0.0;(0.0)") )
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam
Hi @Nasif_Azam , thank you for replying. I tried your code but im getting a syntax error saying the syntax for bps is incorrect. Can you explain why? Your logic does work but i cant see what im doing wrong!
The syntax error you’re encountering is due to how escape characters are being handled within the FORMAT function’s format string in DAX.
The Problem in this expression: FORMAT((Actual - FC) * 10000, "0\"bps\";\"(\"0\")bps\"")
You're attempting to use escaped double quotes \" inside a DAX string, but DAX doesn't use backslashes (\) to escape quotes. Instead, DAX escapes double quotes by doubling them, like this: "".
You should replace all \" with "". Corrected version of your DAX expression:
% Variance Actual vs FC = VAR MetricType = SELECTEDVALUE('Results (2)'[Period]) VAR Actual = SELECTEDVALUE('Results (2)'[MTD Actual]) VAR FC = SELECTEDVALUE('Results (2)'[MTD FC]) RETURN IF( MetricType = "Percentage", FORMAT((Actual - FC) * 10000, "0""bps"";(""0"")bps"), FORMAT(Actual - FC, "0.0;(0.0)") )
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam
Thank you so much @Nasif_Azam , i tweaked it a bit as still wasnt working for negatives but it works now!! Thank you, youre a genius
Thanks for sharing your DAX. I think the issue comes from the way you’re formatting the output for positive numbers — especially in the FORMAT function. In DAX, the format string "0;(0)bps" means:
Use 0 for positive numbers
Use (0)bps for negative numbers
So when the result is positive, it just shows a plain number without the bps suffix.
space waves
Hey @EvaHello ,
The issue in your DAX code lies in the FORMAT function, particularly this part:
FORMAT((Actual - FC)*10000, "0;(0)" & "bps")
"0;(0)" & "bps" is a custom format string for FORMAT.
In DAX, format strings like "0;(0)" define:
Positive numbers: "0"
Negative numbers: "(0)"
You're trying to append "bps" to the result, but:
This only works correctly for negative numbers, because you're formatting it as "(X)bps".
For positive numbers, "0" returns just the number without "bps" and you aren't appending "bps" manually for positive numbers.
To make "bps" appear for both positive and negative values, you can modify the format string to:
"0\"bps\";\"(\"0\")bps\""
The corrected code:
% Variance Actual vs FC = VAR MetricType = SELECTEDVALUE('Results (2)'[Period]) VAR Actual = SELECTEDVALUE('Results (2)'[MTD Actual]) VAR FC = SELECTEDVALUE('Results (2)'[MTD FC]) RETURN IF( MetricType = "Percentage", FORMAT((Actual - FC) * 10000, "0\"bps\";\"(\"0\")bps\""), FORMAT(Actual - FC, "0.0;(0.0)") )
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
75 | |
54 | |
37 | |
31 |
User | Count |
---|---|
99 | |
56 | |
50 | |
42 | |
40 |