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

Join 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.

Reply
FatemaRangwala
Regular Visitor

Format dax produces blanks

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!

1 ACCEPTED SOLUTION
danextian
Super User
Super User

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.





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

4 REPLIES 4
Alex87
Super User
Super User

can you provide a sample data that reproduces your issue?




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!




danextian
Super User
Super User

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.





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.
Alex87
Super User
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




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!




Hi @Alex87 ,

 

But this solution is not working.

 

Thanks

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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