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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
abukapsoun
Post Patron
Post Patron

Returning a value based on a search range

Hi,

 

I am looking for your help finding out the DAX formula to create the following scenario.

thank you

 

NameCountryNew Column  
AAXXif AA has XX in country column, then return XX, else others.  
AAOthersif AA has XX in country column, then return XX, else others.  
AAOthersif AA has XX in country column, then return XX, else others.  
BBXXif BB has XX in country column, then return XX, else others.  
BBXXif BB has XX in country column, then return XX, else others.  
BBOthersif CC has XX in country column, then return XX, else others.  
CCOthersif CC has XX in country column, then return XX, else others.  
1 ACCEPTED SOLUTION

@abukapsoun ,

 

Please see if the following DAX resolves your issue:

Column =
CALCULATE ( MAX ( [Country] ), ALLEXCEPT ( Countries, Countries[Name] ) )

View solution in original post

7 REPLIES 7
Ahmedx
Super User
Super User

abukapsoun
Post Patron
Post Patron

Hi Rajul, but you haven't taken into consideration the Name in the formula?

@rajulshah the result is not as expected. I want to get XX, if it exists in the whole range of countries for Name=AA

so for each name, the formula should look into the whole range of country column, and if XX is found at least once, then return XX. 

 

AA might have multiple lines, however in the country column it is either XX or others. So I want to do a kind of search, and if XX is found once, then return XX

@abukapsoun ,

 

Please see if the following DAX resolves your issue:

Column =
CALCULATE ( MAX ( [Country] ), ALLEXCEPT ( Countries, Countries[Name] ) )

@abukapsoun ,

 

Oh okay, let me just work it that way then.

rajulshah
Resident Rockstar
Resident Rockstar

@abukapsoun ,

 

Please try the below DAX formula. Please know that I have assumed that you want if there is any country present then we should get the value of country else Others.

Column =
IF ( [Country] <> "Others", [Country], "Others" )

 

Please let me know if this is not what you want.

@abukapsoun , please mark the post as solution if your issue is resolved. Thanks.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors