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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jwhy
Regular Visitor

M Script - Conditional Formula with Nested IF OR AND

Hi,

 

I'm fairly new to Power BI so seeing if someone can help me with my script or if the issue lies in my data.

 

The formula i'm trying to create and having issues with is located on the second line. If Fiscal Year doesn't equal 2020 and 2017, and Account Code equals 527990, then insert 0. Without this line, I don't have any issues, but when I insert (2020 or 2017), I get the error below.

 

There are no blanks in Fiscal Year, and both Data Types are consistent of Whole Numbers.

 

help.png

help2.png

 

Help is appreciated!

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Whoops sorry I focussed on the error only.

The logic now doesn't make sense, because the OR part always evaluates to True. A year is always either not 2020 or not 2017.

Make that or statement an and statement, that should help.

Alternatively write out your logic and provide us with sample data and we can help you out:)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
JarroVGIT
Resident Rockstar
Resident Rockstar

The problem is in the (2020 or 2017) part. the OR operator expects two seperate comparisons, not a summation of elements.

 

Try this

 

else if ([Fiscal Year]<>2020 or [Fiscal Year]<>2017) and .....

 

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Kudo's are welcome 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for the explanation and solution Djerro, it solved the error issue however I think due to my "not" <> operator and order of things, it's spitting out results i'm not looking for. I tried to just target the combination of Fiscal Year and Account Code for each year, i.e. Fiscal Year 2018 and Account Code #### then 0, but still not getting the correct results.

 

Will play around more and update if I find a solution.

JarroVGIT
Resident Rockstar
Resident Rockstar

Whoops sorry I focussed on the error only.

The logic now doesn't make sense, because the OR part always evaluates to True. A year is always either not 2020 or not 2017.

Make that or statement an and statement, that should help.

Alternatively write out your logic and provide us with sample data and we can help you out:)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors