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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tameemyousaf
Helper I
Helper I

Search in column with many to many relationship

Hi,

 

I have two table with name Actual & FlowTypeControl. I need to add a new column in Actual table based on text search (it will be trigger column from FlowTypeControl table) from comments column. 

 

Condition for new column will be like this:

 

IF Comments like FlowTypeControl.Trigger Then FlowTypeControl.FlowType ELSE Blank

 

Below are the screenshots of tables with sample data and required results.

 

tameemyousaf_0-1626292011972.png

 

tameemyousaf_1-1626292086719.png

 

tameemyousaf_2-1626292150220.png

 

Can anyone help?

 

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

The CONTAINSSTRING function is useful here.

 

ActualFlowType =
VAR CRK = Actual[CountryRegionKey]
VAR Comments = Actual[Comments]
RETURN
    MAXX (
        FILTER (
            FlowTypeControl,
            FlowTypeControl[CountryRegionKey] = CRK
                && CONTAINSSTRING ( Comments, FlowTypeControl[Trigger] )
        ),
        FlowTypeControl[FlowType]
    )

 

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @tameemyousaf,

Did AlexisOlson 's suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements to find it more quickly.

If these also not help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
AlexisOlson
Super User
Super User

The CONTAINSSTRING function is useful here.

 

ActualFlowType =
VAR CRK = Actual[CountryRegionKey]
VAR Comments = Actual[Comments]
RETURN
    MAXX (
        FILTER (
            FlowTypeControl,
            FlowTypeControl[CountryRegionKey] = CRK
                && CONTAINSSTRING ( Comments, FlowTypeControl[Trigger] )
        ),
        FlowTypeControl[FlowType]
    )

 

Thanks @AlexisOlson

 

One more question, is there any way if we give just one region in FlowTypeControl table and set country blank and it will give data of all countries in that region. For example, if i give just North America and blank country then it should show the data for all the countries in North America. All countries of North America will be present in Actual table

I'm not sure where you "set country" or where "it will give data". Are you talking about slicer and visuals or measure variables and calculated tables or what?

@AlexisOlson I am not talking about any measure or table. I am talking about the data. When we add data in flowTypeControl table like this. Then how can we handle the situation of all countries.

 

tameemyousaf_0-1626462978426.png

 

 

 

How about matching on Region and Country separately rather than using the combined key and replacing blank with All?

 

ActualFlowType =
VAR Region = Actual[Region]
VAR Country = IF ( ISBLANK ( Actual[Country] ), "All", Actual[Country] )
VAR Comments = Actual[Comments]
RETURN
    MAXX (
        FILTER (
            FlowTypeControl,
            FlowTypeControl[Region] = Region
                && FlowTypeControl[Country] = Country
                && CONTAINSSTRING ( Comments, FlowTypeControl[Trigger] )
        ),
        FlowTypeControl[FlowType]
    )

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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