Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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.
Proud to be a Super User!
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.
Proud to be a Super User!
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
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
115 | |
112 | |
105 | |
95 | |
58 |
User | Count |
---|---|
174 | |
147 | |
136 | |
102 | |
82 |