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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

if Function in Custom Column - Why won't my Function accurately calculate the results?

I have an if Function that is working fine in terms of being able to calculate the results with no errors. The problem is I am currently learning PowerBI and Power Query through projects at work and I am unsure why the function I have written (in DAX via Custom Column - see below) isn't working correctly. 

 

All of my returning results are calculated as "Include" and there are multiple rows (16 to be exact) that should be calculated as "Exclude". All of the Columns references have been formatted to "Text" Value as well (see photo 2).

 

Formula Written in Custom Column

 

= if [CURR_STG_NAME]="Transacted - Lost" & [SPEC_STG_CD]="Marketing Lead" & [Days in Sale Cycle Stages]="0" then "Exclude" else "Include"

 

= if [CURR_STG_NAME]="Transacted - Lost" & [SPEC_STG_CD]="Marketing Lead" & [Days in Sale Cycle Stages]="0" then "Exclude" else "Include"

 

 

I have had to mark-out the column information as this is a work project and I am using privacy sensitive data (second photo only has the "Include" results that should be "Exclude"). But the only resulting rows are "Include" & there are still rows that would be "Exclude" as a result, returning as "Include", with that said on the Raw excel file, the "exclude" total was equal to the rows that would be "Exclude" as a result, returning as "Include". I am struggling to figure out how to get 100% accuracy to the function without syntax errors.  

 

I have tried the && instead of & with no success as the Syntax Error results with Token Literal Expected and the red squiggle underneath the "E" in [SPEC_STG_CD]. 

 

Photo 1

Created-Opty Include-Exclude Function.PNG

  

 

Photo 2

Created-Opty Include-Exclude if Function Pt.2.PNG

 

Hopefully this is enough context to recieve some guidance from the community, I appreciate anyone who has any thoughts or ideas! 

 

Thanks! 

1 ACCEPTED SOLUTION
cpearson
Resolver I
Resolver I

Try changing your &'s to and... i.e.

 

 

= if [CURR_STG_NAME]="Transacted - Lost" and [SPEC_STG_CD]="Marketing Lead" and [Days in Sale Cycle Stages]="0" then "Exclude" else "Include"

 

View solution in original post

2 REPLIES 2
cpearson
Resolver I
Resolver I

Try changing your &'s to and... i.e.

 

 

= if [CURR_STG_NAME]="Transacted - Lost" and [SPEC_STG_CD]="Marketing Lead" and [Days in Sale Cycle Stages]="0" then "Exclude" else "Include"

 

Anonymous
Not applicable

Thank you!! That worked!

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.