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

Each if multiple criterias

Hello, 

 

This video perfectly taught what I wanted to do - https://www.youtube.com/watch?v=cOXNbaa_02U&ab_channel=Curbal

 

I'm hoping to add more factors into the each if statement. The issue I am facing is that 16 out of 20 people who are on international assignment are People managers and I need to classify them as such. But I don't have a format to deal with the 4 who are not. Since the list of people is small, my solution was to add another criteria into the each if statement but I'm a beginner so I'm unsure how to do so. 

 

Would the best solution be:
1.if international assignment is yes 

2. worker name is not (john, alex, abel, cain)

3. Then  [Job role] = "People Manager"

4. Else [Job role]

 

 

= Table.AddColumn(#"Filtered Rows", "CJF Job Level Edited", each if [International Assignment] = "yes" then [Job Role] = "People Manager" else [Job Role])

 

Thank you!

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Please try my M code in Power Query.

Custom column:

if [International Assignment] = "Yes" then 
if List.Contains({"John","Alex","Abel","Cain"},[Name]) then "Not People Manager" else "People Manager" else "Not in International Assignment"

1.png

You see By this code, in my custom column, people with "Yes" and is not in four people will return "People Manager", people with "Yes" and is in four people will return "Not People Manager", and other people with "No" will return "Not in International Assignment".

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Please try my M code in Power Query.

Custom column:

if [International Assignment] = "Yes" then 
if List.Contains({"John","Alex","Abel","Cain"},[Name]) then "Not People Manager" else "People Manager" else "Not in International Assignment"

1.png

You see By this code, in my custom column, people with "Yes" and is not in four people will return "People Manager", people with "Yes" and is in four people will return "Not People Manager", and other people with "No" will return "Not in International Assignment".

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Ashish_Mathur
Super User
Super User

Hi,

Ideally you should create another table with a single column of Names to be excluded and join that single column table into your main table.  So rows where the names match in both tables will display as TRUE in a new column of your main table otherwise FALSE.  Thereafter, write this Custom Column formula in the Query Editor

Table.AddColumn(#"Filtered Rows", "CJF Job Level Edited", each if [International Assignment] = "yes" then if [Match Name]=FALSE then [Job Role] = "People Manager" else "Don't know" else [Job Role])

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.