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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
babajat
Frequent Visitor

IF any of the colums equal any of the value

Hello!

 

I've got this data:

IDVALUE 1VALUE 2VALUE 3VALUE 4
116020
2XYZ000
30000
400XYZ0
50020
60100
70ABC016
84000
90000
100402
11XYZ10XYZ
125070
130200
14040XYZ
15ABC030

 

I'm trying to add a new that return 1 if any of the "VALUE" columns is equal to "XYZ" or "1" or "3", if not it returns 0.

Like this one just to be clear:

IDVALUE 1VALUE 2VALUE 3VALUE 4NEW COLUMN
1160200
2XYZ0001
300000
400XYZ01
500200
601001
70ABC0160
840000
900000
1004020
11XYZ10XYZ1
1250700
1302000
14040XYZ1
15ABC0301

 

For now I have only managed to do it with this atrocious formula:

NEW COLUM = if('Report 1'[VALUE 1] = "XYZ" || 'Report 1'[VALUE 1] = "1" || 'Report 1'[VALUE 1] = "3"  || 'Report 1'[VALUE 2] = "XYZ" || 'Report 1'[VALUE 2] = "1" || 'Report 1'[VALUE 2] = "3" || 'Report 1'[VALUE 3] = "XYZ" || 'Report 1'[VALUE 3] = "1" || 'Report 1'[VALUE 3] = "3" || 'Report 1'[VALUE 4] = "XYZ" || 'Report 1'[VALUE 4] = "1" || 'Report 1'[VALUE 4] = "3", 1, 0)
 
It gets the job done but it also takes a long time to write and I have to write several ones like this one.
 
Is there a more efficient way to do it?
 
Thanks in advance.
1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@babajat 

Here is a link to download a sample solution file:

IF any of the colums equal any of the value 2022-08-09.pbix

 

Column = 
INT(
    'Table'[VALUE 1] IN {"XYZ", "1", "3"} 
    || 'Table'[VALUE 2] IN {"XYZ", "1", "3"} 
        || 'Table'[VALUE 3] IN {"XYZ", "1", "3"} 
            || 'Table'[VALUE 4] IN {"XYZ", "1", "3"} 
)

 

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Showcase Report – Contoso By SpartaBI

Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

View solution in original post

1 REPLY 1
SpartaBI
Community Champion
Community Champion

@babajat 

Here is a link to download a sample solution file:

IF any of the colums equal any of the value 2022-08-09.pbix

 

Column = 
INT(
    'Table'[VALUE 1] IN {"XYZ", "1", "3"} 
    || 'Table'[VALUE 2] IN {"XYZ", "1", "3"} 
        || 'Table'[VALUE 3] IN {"XYZ", "1", "3"} 
            || 'Table'[VALUE 4] IN {"XYZ", "1", "3"} 
)

 

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Showcase Report – Contoso By SpartaBI

Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.