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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
gauravnarchal
Post Prodigy
Post Prodigy

Need help with TRUE function

Hello  -  I want to create a measure to get the result as true or false for the below 2 conditions.

 

  1. If the location starts with SIE and contains locations RUI or KLT orAKL then return true else false

 

  1. If the location starts and ends with SIE and contains locations RUI & KLT or AKL then return true else false

 

Data 

 

Table1

Location
SIE*KLT*JTR/MIL
SIE*KLT*MIL
MIL*KLT*MIL
KLT*MIL*KLT
SIE*KLT*RUI*MIL
SIE*RUI*KLT*MIL
SIE*JUY*KLT*MIL
SIE*JUY*KLT*MIL*SIE
SIE*RUI*KLT*MIL*SIE
SIE*PLI*SIE
SIE*QWE*SIE
SIE*AKL/SIE
SIE*AKL
SIE*AKL*PLO
SIE*RUI/KLT*MIL
SIE*JUY*KLT

 

Thanks

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @gauravnarchal 

 

You can try the following function to write measure.

 

Measure1 = LEFT ( MAX('Table'[Location]), 3 ) = "SIE"
    && (
        CONTAINSSTRING ( MAX('Table'[Location]), "RUI" )
            || CONTAINSSTRING ( MAX('Table'[Location]), "KLT" )
            || CONTAINSSTRING ( MAX('Table'[Location]), "AKL" )
)
Measure2 = 
LEFT ( MAX ( 'Table'[Location] ), 3 ) = "SIE"
    && RIGHT ( MAX ( 'Table'[Location] ), 3 ) = "SIE"
    && (
        CONTAINSSTRING ( MAX ( 'Table'[Location] ), "RUI" )
            || CONTAINSSTRING ( MAX ( 'Table'[Location] ), "KLT" )
            || CONTAINSSTRING ( MAX ( 'Table'[Location] ), "AKL" )
)

 

vzhangti_0-1637285008836.png

 

Best Regards,

Community Support Team _Charlotte

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
v-zhangti
Community Support
Community Support

Hi, @gauravnarchal 

 

You can try the following function to write measure.

 

Measure1 = LEFT ( MAX('Table'[Location]), 3 ) = "SIE"
    && (
        CONTAINSSTRING ( MAX('Table'[Location]), "RUI" )
            || CONTAINSSTRING ( MAX('Table'[Location]), "KLT" )
            || CONTAINSSTRING ( MAX('Table'[Location]), "AKL" )
)
Measure2 = 
LEFT ( MAX ( 'Table'[Location] ), 3 ) = "SIE"
    && RIGHT ( MAX ( 'Table'[Location] ), 3 ) = "SIE"
    && (
        CONTAINSSTRING ( MAX ( 'Table'[Location] ), "RUI" )
            || CONTAINSSTRING ( MAX ( 'Table'[Location] ), "KLT" )
            || CONTAINSSTRING ( MAX ( 'Table'[Location] ), "AKL" )
)

 

vzhangti_0-1637285008836.png

 

Best Regards,

Community Support Team _Charlotte

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

AlexisOlson
Super User
Super User

You can do this with LEFT and CONTAINSSTRING.

LEFT ( Table1[Location], 3 ) = "SIE"
    && (
        CONTAINSSTRING ( Table1[Location], "RUI" )
            || CONTAINSSTRING ( Table1[Location], "KLT" )
            || CONTAINSSTRING ( Table1[Location], "AKL" )
    )

 

 

mattww
Responsive Resident
Responsive Resident

@gauravnarchal 

 

Something along the lines of a Custom Column in Power Query like

 

if Text.StartsWith([Location],"SIE") and (Text.Contains([Location],"RUI") or Text.Contains([Location],"KLT") or Text.Contains([Location],"AKL")) then true
else false

 

 

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

mattww
Responsive Resident
Responsive Resident

Hi @gauravnarchal, are you ok with this being in Power Query, not DAX?

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors