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
hyperbob0811
Frequent Visitor

Nested If formula in Power Bi Query custom column issue

I have the following code in a custom column, and it simply refuses to accept any variant of the very first then string value I want to add.  Doesnt matter what I do, I get the same error. this seems like basic functionality, but i cannot get it to work at all.  (I Can get it to work on the table view, but I really want this within the query.

 

hyperbob0811_0-1595509729829.png

 

Any help will be greatly appreciated as I need this custom column for use elsewhere in the power bi report

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@hyperbob0811 - You don't use the paren's with if statements in M code. That's DAX syntax.

 

Should be:

 

if [alpha_code] = ...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@hyperbob0811 - You don't use the paren's with if statements in M code. That's DAX syntax.

 

Should be:

 

if [alpha_code] = ...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks, now I get a token else error - how do I end this formula?

@hyperbob0811 - Add else "" or something like that.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

excellent thanks - I was in full DAX and excel mode with the parenthesis and comma's - this seems like you basically right it out as you would say it!

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.