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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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