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
Anonymous
Not applicable

Convert SQL to DAX

Will someone please convert this sql to dax for me?

 

case when nvl (STAFF_ABILITY_RESOLVE_ISSUES, 'N/A') = 'N/A' then null else to_number (STAFF_ABILITY_RESOLVE_ISSUES) end as atri,

 

I need to get the N/A values in the field to become nulls and at the same time convert the entire column to number format, specifically decimal if possible. I am in direct query mode in the query editor so it does not allow me to convert the column so I am hoping this statement will allow it!!

 

Thanks

11 REPLIES 11
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please try this code.

=if  [STAFF_ABILITY_RESOLVE_ISSUES]= "N/A" then null else Decimal.From([STAFF_ABILITY_RESOLVE_ISSUES])

1.PNG

 

Alternatively, you can directly choose Decimal Number under the data type list. 

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Phil_Seamark
Microsoft Employee
Microsoft Employee

HI @Anonymous

 

Please try this

 

Column = 
    SWITCH(
        TRUE() ,
        ISNUMBER('Table1'[STAFF_ABILITY_RESOLVE_ISSUES]), FIXED('Table1'[STAFF_ABILITY_RESOLVE_ISSUES],2),
        BLANK()
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

@Phil_Seamark Expression.Error: The name 'SWITCH' wasn't recognized.  Make sure it's spelled correctly.

Hi there,

 

Are you using Power BI and are you doing this in DAX or in the Query Editor?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

@Phil_Seamark Hey Phil! I am using query editor in power BI desktop. Custom Column

all above solution were provided using DAX, if you are in query editor, on add customr column, you need to do following:

 

if  STAFF_ABILITY_RESOLVE_ISSUES = "N/A" then 
null
else STAFF_ABILITY_RESOLVE_ISSUES


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k Hello, Can you help me with a forumal that will convert the entire column in to a decimal number format in the same statement? The problem is that even if I I substiture the N/A for null, I need the entire column to be number... the direct query mode doesn't allow me to just simply convert it to decimal format...

Anonymous
Not applicable

@parry2k 

I have tried using to_number and value but it didn't like those words:

if [AMENITIES] = "N/A" then null else to_number ([AMENITIES])

if [AMENITIES] = "N/A" then null else value ([AMENITIES])

 

Any ideas of a better word there that would be accepted?

 

Thank you in advance for your kind help!

vega
Resolver III
Resolver III

Does this work for you?

 

IF(
   STAFF_ABILITY_RESOLVE_ISSUES = "N/A", 
   BLANK(),
   VALUE(STAFF_ABILITY_RESOLVE_ISSUES)
)
Anonymous
Not applicable

@vega  Expression.Error: The name 'IF' wasn't recognized.  Make sure it's spelled correctly.

Anonymous
Not applicable

Expression.Error: The name 'IF' wasn't recognized.  Make sure it's spelled correctly.

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.