Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi PowerBI Community,
I am facing an issue with the FORMAT DAX function.
I have a few measures that divide and produce the output in % form and I am using this output in the SWITCH DAX if account code = a then this if account code = b then this and if I use this switch measure as general FORMAT it will return correct output without blanks i.e.,
SWITCH(
MAX( 'TableName'[account code] ),
"account_code", [measurename],
"account_code", [measurename],
)
but if we use FORMAT to convert it to % it returns the output with blanks:
SWITCH(
MAX( 'TableName'[account code] ),
"account_code", FORMAT( [measurename], "#0.00%" ),
"account_code", [measurename],
)
Anyone has any idea how to avoid blanks while using FORMAT but not modifying the DAX or not using blank function to avoid it as the dataset is quite huge so it is degrading the performance and also we cannot convert the whole measure as % as we have net sales in that.
Your response will be appreciated.
Thank You in advance!
Solved! Go to Solution.
Hi @FatemaRangwala ,
If the referenced measure returns blank, I dont see any other reason for FORMAT to return as such. You can add + 0 or -0 after the referenced measure in your formula so it shows zero when blank.
=
SWITCH (
MAX ( 'TableName'[account code] ),
"account_code", FORMAT ( [measurename] + 0, "#0.00%" ),
"account_code", [measurename]
)
Alternatively, look into dynamic format strings so your measure still returns a number but formatted instead of text if FORMAT is used.
can you provide a sample data that reproduces your issue?
Hi @FatemaRangwala ,
If the referenced measure returns blank, I dont see any other reason for FORMAT to return as such. You can add + 0 or -0 after the referenced measure in your formula so it shows zero when blank.
=
SWITCH (
MAX ( 'TableName'[account code] ),
"account_code", FORMAT ( [measurename] + 0, "#0.00%" ),
"account_code", [measurename]
)
Alternatively, look into dynamic format strings so your measure still returns a number but formatted instead of text if FORMAT is used.
Hello,
True using this:
VAR _Condition = MAX('TableName'[account code])
VAR _Result =
SWITCH(
TRUE(),
_Condition = "account_code", FORMAT([measurename], "#0.00%"),
_Condition = "another_code", FORMAT([measurename], "#0.00"),
FORMAT([measurename], "#0.00%")
)
RETURN _Result
If it helps, please mark my reply as the solution. Thanks
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 |
---|---|
66 | |
62 | |
52 | |
36 | |
34 |
User | Count |
---|---|
78 | |
66 | |
58 | |
45 | |
43 |