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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
walker4545
Frequent Visitor

Calculated Column in DAX to check if values appear in another column, create an array from a table

Hello Power BI gurus, 

 

I need help with the following problem. I need to create a calculated column that evaluates whether a value appears in another column. 

 

Flag

Flag Colours
Red
White
Blue

 

Primary

Primary Colours
Red
Yellow
Blue

 

Primary Colour =
    VAR PrimaryArray = {"Red", "Blue", "Yellow"}
    VAR CheckPrimary = IF('Flag'[Flag Colours] IN PrimaryArray, "Primary Colour", "Not Primary Colour")
    RETURN CheckPrimary
 
The above code is a solution of how I would like the code to work (to calculate a column based on whether a value appears in an array). In the code above I'd like to replace the code in italics to bring in values from the column of another table. However, when attempting to declare the variable PrimaryArray against a column in the Primary Table I cannot access those values. 
 
How can I bring in the values from 'Primary'[Primary Colours] into an array that can be evaluated against to match values?
 
Thanks in advance!
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@walker4545 , Try like

 

Primary Colour =
VAR PrimaryArray = values(Primary[Primary Colours])
VAR CheckPrimary = IF('Flag'[Flag Colours] IN PrimaryArray, "Primary Colour", "Not Primary Colour")
RETURN CheckPrimary

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@walker4545 , Try like

 

Primary Colour =
VAR PrimaryArray = values(Primary[Primary Colours])
VAR CheckPrimary = IF('Flag'[Flag Colours] IN PrimaryArray, "Primary Colour", "Not Primary Colour")
RETURN CheckPrimary

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors