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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
KH_Mike
Helper III
Helper III

Match Serval Text in Measure

Hi All,

 

Right now, I am using contains function to match the text in "Measure" and show it in "Table". May I know if there is any easy way to acheive the same result ? If possible, is it able to do it in wild match? (I would like to do it in visualization instead of add new column in dataset).

 

My current express in Measure is as follow.

 

Measure = if(CONTAINS(Data,Data[Country],"USA")||CONTAINS(Data,Data[Country],"CANADA"),"AMR",values(Data[Country]))
1 ACCEPTED SOLUTION

Hi @KH_Mike ,

 

Try

Measure=
SWITCH (
    MAX ( 'Data'[Country] ),
    "USA", "AMR",
    "CANADA", "AMR",
    MAX ( 'Data'[Country] )
)

or

Measure=
IF (
    MAX ( 'Data'[Country] ) = "USA"
        || MAX ( 'Data'[Country] ) = "CANADA",
    "AMR",
    MAX ( 'Data'[Country] )
)

The MAX function is equivalent to getting the value of the current row, and the MIN function can also achieve the same effect.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@KH_Mike , I think you have to do like, what you are doing

 

 

Measure = if(CONTAINSSTRING(Data,Data[Country],"USA") || CONTAINSSTRING(Data,Data[Country],"CANADA"),"AMR",Data[Country])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak ,

 

I want to know if there is any function like Switch in Excel can make it formula short. Also, if I only input "Data[Country]" at the end. It seems can't work  correctly.

Hi @KH_Mike ,

 

Try

Measure=
SWITCH (
    MAX ( 'Data'[Country] ),
    "USA", "AMR",
    "CANADA", "AMR",
    MAX ( 'Data'[Country] )
)

or

Measure=
IF (
    MAX ( 'Data'[Country] ) = "USA"
        || MAX ( 'Data'[Country] ) = "CANADA",
    "AMR",
    MAX ( 'Data'[Country] )
)

The MAX function is equivalent to getting the value of the current row, and the MIN function can also achieve the same effect.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-stephen-msft,

 

That exactly what I need. Thank you. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.