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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
misul
Helper I
Helper I

Nested IF formulas with OR statement

Hello PBI Community, 

What would be a way to simplify this nested if statement?

 

Existing columns, X, Y related to other dimension tables.

 

Result=
IF (related (X)=A1 || related (Y)= A1, A1,

IF (related (X)=B1 || related (Y)=B1, B1,

IF (related (X)=C1 || related (Y)=C1, C1,

IF (related (X)=D1 || related (Y)=D1, D1,

IF (related (X)=E1 || related (Y)=E1, E1,

IF (related (X)=F1 || related (Y)=F1, F1,

IF (related (X)=G1 || related (Y)=G1, G1,

IF (related (X)=H1 || related (Y)=H1, H1,

"None" ))))))))

 

 Thank you for your support!

 

 

 

5 REPLIES 5
OwenAuger
Super User
Super User

Hi @misul

I agree with @Stachu's logic, and you could implement this something like below.

Note that this depends on the lookup values being the same as the return values.

 

Result =
VAR ValueList = { "A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1" }
VAR X =
    RELATED ( YourTable[X] )
VAR Y =
    RELATED ( YourTable[Y] )
VAR LookupResult =
    FIRSTNONBLANK ( ValueList, IF ( OR ( [Value] = X, [Value] = Y ), 1 ) )
RETURN
    IF ( ISBLANK ( LookupResult ), "None", LookupResult )

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

@Stachu @OwenAuger Thanks for your tips. For my original problem your solution helps.

 

However, I have run into another issue which is that the last item from ValueList ("H1") is never returned,because of its position at the end of the list.

 

The new problem is that :

 

 

 

I am trying to create 1 new column [Result] based on a two columns [X] and [Y]. Both columns [X] and [Y] have the same 8 distinct values (A1... H1).

 

If I filter for A1, I want it to return all rows where both [X] is A1 and [Y] is A1.

 

Stachu
Community Champion
Community Champion

hmm, doesn't this approach require multiple values in a column?
say I have X,Y in following format
X|Y
A1|A1
A1|B1
so in this case the Result should be something like this (to properly filter B1):
Result
A1
A1,B1
I think in this case it's best to create separate table for the slicer with just A1:H1, and propagate filter to X & Y from there



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

@misul

Sure - should be able to do that.

Just to clarify, do you want a way of filtering on the values A1..H1, then if, for example someone filters on A1, you return the union of rows where either [X] is A1 or [Y] is A1?

 

Could you post a quick example to confirm?

 

Thanks

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn
Stachu
Community Champion
Community Champion

can you share the sample data from tables containing X,Y, and the table where you add the calculated column?

my way of thinking would be - if you could determine A1-H1 with VAR then the syntax could be like this

Result = 
VAR varParameter = "A1:H1" //some proper syntax here
RETURN
IF(RELATED(X)=varParameter || RELATED(Y) = varParameter, varParameter, "None")


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.