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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.