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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
trevordunham
Helper II
Helper II

Create group with overlapping entries

I want to create a group from the following measure:

 

Activity (which has  the following options):

AA

AB

BC

CC

 

I want to create the following groups that contain:

A : (AA, AB)

B: (AB, BC)

C: (BC, CC)

 

Is there a way to create a group with overlaps such as this? When I try to just simply create the group it doesn't allow overlaps like Tableau does.

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Here are a couple of ways. 

1) Create a new independent table in the model for the Group Values  to use in the visual:

Group = 
DISTINCT(SELECTCOLUMNS('Activity Table', "Group", LEFT('Activity Table'[Activity])))

Group table.png

Next create the following measure:

Acitivties by Group =
VAR _T1 =
    DISTINCT (
        SELECTCOLUMNS (
            'Activity Table',
            "@Group", LEFT ( 'Activity Table'[Activity] )
        )
    )
VAR _T2 =
    VALUES ( 'Activity Table'[Activity] )
VAR _FT =
    CROSSJOIN ( _T1, _T2 )
VAR _Filtered =
    ADDCOLUMNS (
        FILTER (
            _FT,
            CONTAINSSTRING ( 'Activity Table'[Activity], [@Group] ) = TRUE ()
        ),
        "@Activity", [Activity]
    )
RETURN
    CONCATENATEX (
        FILTER ( _Filtered, [@Group] IN VALUES ( 'Group'[Group] ) ),
        [@Activity],
        ", "
    )

Add the Group[Group] field and the measure to the visual to get:

result.png

 

2) Creating a new table with both group and activity + a measure:

Table Method =
VAR _T1 =
    DISTINCT (
        SELECTCOLUMNS (
            'Activity Table',
            "TM Group", LEFT ( 'Activity Table'[Activity] )
        )
    )
VAR _T2 =
    VALUES ( 'Activity Table'[Activity] )
VAR _FT =
    CROSSJOIN ( _T1, _T2 )
VAR _Filtered =
    FILTER (
        _FT,
        CONTAINSSTRING ( 'Activity Table'[Activity], [TM Group] ) = TRUE ()
    )
RETURN
    _Filtered

TM Table.png

 and the measure

Table method measure = CONCATENATEX(VALUES('Table Method'[Activity]), 'Table Method'[Activity], ", ")

TM result.png

 

 

I've attached the sample PBIX file

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

Here are a couple of ways. 

1) Create a new independent table in the model for the Group Values  to use in the visual:

Group = 
DISTINCT(SELECTCOLUMNS('Activity Table', "Group", LEFT('Activity Table'[Activity])))

Group table.png

Next create the following measure:

Acitivties by Group =
VAR _T1 =
    DISTINCT (
        SELECTCOLUMNS (
            'Activity Table',
            "@Group", LEFT ( 'Activity Table'[Activity] )
        )
    )
VAR _T2 =
    VALUES ( 'Activity Table'[Activity] )
VAR _FT =
    CROSSJOIN ( _T1, _T2 )
VAR _Filtered =
    ADDCOLUMNS (
        FILTER (
            _FT,
            CONTAINSSTRING ( 'Activity Table'[Activity], [@Group] ) = TRUE ()
        ),
        "@Activity", [Activity]
    )
RETURN
    CONCATENATEX (
        FILTER ( _Filtered, [@Group] IN VALUES ( 'Group'[Group] ) ),
        [@Activity],
        ", "
    )

Add the Group[Group] field and the measure to the visual to get:

result.png

 

2) Creating a new table with both group and activity + a measure:

Table Method =
VAR _T1 =
    DISTINCT (
        SELECTCOLUMNS (
            'Activity Table',
            "TM Group", LEFT ( 'Activity Table'[Activity] )
        )
    )
VAR _T2 =
    VALUES ( 'Activity Table'[Activity] )
VAR _FT =
    CROSSJOIN ( _T1, _T2 )
VAR _Filtered =
    FILTER (
        _FT,
        CONTAINSSTRING ( 'Activity Table'[Activity], [TM Group] ) = TRUE ()
    )
RETURN
    _Filtered

TM Table.png

 and the measure

Table method measure = CONCATENATEX(VALUES('Table Method'[Activity]), 'Table Method'[Activity], ", ")

TM result.png

 

 

I've attached the sample PBIX file

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@trevordunham , You have to create a table with these duplicate values and join it with your table. Force a many to many join and filter from that new table to this table

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.