cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BhaktaTheFuture
New Member

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"

 

Thank you!! That worked!

Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors