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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
HassanAli123
Helper I
Helper I

if else with or and is not working

Hi,
   I have two columns
       1) Labour class
       2) HRMS
i am using the following m query code attached in picture but it is not giving correct result.
First 3 conditions are giving correct result but fourth one is not correct.

4th condition is bringing foreman too i dont want to see foreman. what is wrong with that. is there any syntax problem?
i am using text.start because foreman value is not separate.

 

measure.PNG

 Data view.PNG

6 REPLIES 6
wdx223_Daniel
Super User
Super User

= List.Skip({"Foreman","Senior Foreman","Supervisor"},each not Text.StartsWith([HRMS],_,Comparer.OrdinalIgnoreCase)){0}? ??if List.Contains({"1AA","1bb"},[labour Calss]) then "Junior Staff" else null)

Hi @wdx223_Daniel  it is giving error on if as i have attached SS.


Error.PNG

= List.Skip({"Foreman","Senior Foreman","Supervisor"},each not Text.StartsWith([HRMS],_,Comparer.OrdinalIgnoreCase)){0}? ??(if List.Contains({"1AA","1bb"},[labour Calss]) then "Junior Staff" else null))

HotChilli
Super User
Super User

Can you provide sample data or a picture which shows the problem please?  

We need to see 3 columns and the right/wrong values which are being generated so that we can debug

I applied the condition where labour class is 1A and 1B but it is showing 1A and F9 in labour class colum.
and in HRMS colum it is showing Foreman while i applied HRMS not in Foreman.
Note:- there are two value of foreman one is capital and second one is in small letter.

88.PNG

FYI that Power Query is case sensitive. You can uppercase your column and then use all uppercase for the text values in your if. Or you can use Text.Upper or Text.Lower within your expression.

 

Pat

Microsoft Employee

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Solution Authors
Top Kudoed Authors