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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Error in DAX?

I have written this formula as a part of custom column:

 

if[GRP]="3" then "Contract" else if[GRP]="4" then Contract" else if[GRP]="6" then "Contract" else if[GRP]="7" then "Contract" else if[GRP]="9" then "Contract" else if[GRP]="2" then "Contract" else if([GRP]="B" and [JOB] <> 12345) then "Contract" else "Regular Employee"

 

I executed the same for another table and it worked but whenn I create the same for another table and check for else if([GRP]="ZY" and [JOB] <> 12345) then "Contract" with filters it does not show regular for the job = 12345.

 

Any idea as to why this could happen? Because, it gets executed perfectly in another table. Basically if GRP=B and JOB is not equal to 12345 then it is under contract else, regular. But when I filter for GRP=B and JOB=12345 it still comes under contract for me. 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hey, I tried the same code again with the text instead of code and it worked

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @Anonymous,

 

According to your description, I think your formula is m query instead of dax formula.

 

You can try to use below formula if it sutiable for your scenario.

 

M query formula:

#"Added Custom" = Table.AddColumn(#"Preview step", "Custom column", each if List.Contains({"2","3","4","6","7","9"},[GRP]) or ([GRP]="B" and [JOB] <> 12345) then "Contract" else "Regular Employee")

 

Dax formule:

Dax formula=
IF (
    OR (
        [GRP] IN { "3", "4", "6", "7", "9", "2" },
        AND ( [GRP] = "B", [JOB] <> 12345 )
    ),
    "Contract",
    "Regular Employee"
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hey, I tried the same code again with the text instead of code and it worked

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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