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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mcam99
Frequent Visitor

Add Column Group by

I have the following query to create groups where an entity exists in more than 1 group

 

ie

User 1, Mobile

User 1, Desktop

=

User 1, Mobile,Desktop

 

My issue is where I have a different primary groups but the same secondary group it creates the following 

 

Facebook,Mobile,Mobile
Mobile
Mobile,Desktop
Mobile,Mobile

 

Where as I want the results grouped like

 

Facebook,Mobile
Mobile
Mobile,Desktop

 

Below is the current DAX syntax I am using, can anyone help ?

 

Thanks in advance

 

 

Attributes = ADDCOLUMNS(
GROUPBY(
Control,
Control[UUID]
),
"PrimaryGroup",
CALCULATE(
CONCATENATEX(Control, Control[PrimaryGroup], ","),Control[IsFootfall] = 0),
"SecondaryGroup",
CALCULATE(
CONCATENATEX(Control, Control[SecondaryGroup], ","),Control[IsFootfall] = 0)
)

 

 

 

1 ACCEPTED SOLUTION

@mcam99

 

Try this one

 

Attributes =
ADDCOLUMNS (
    GROUPBY ( Control, Control[UUID] ),
    "PrimaryGroup", CALCULATE (
        CONCATENATEX (
            VALUES ( Control[PrimaryGroup] ),
            Control[PrimaryGroup],
            ",",
            Control[PrimaryGroup]
        ),
        Control[IsFootfall] = 0
    ),
    "SecondaryGroup", CALCULATE (
        CONCATENATEX (
            VALUES ( Control[SecondaryGroup] ),
            Control[SecondaryGroup],
            ",",
            Control[SecondaryGroup]
        ),
        Control[IsFootfall] = 0
    )
)

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

@mcam99

 

Please Give this a shot

 

Attributes =
ADDCOLUMNS (
    GROUPBY ( Control, Control[UUID] ),
    "PrimaryGroup", CALCULATE (
        CONCATENATEX ( VALUES ( Control[PrimaryGroup] ), Control[PrimaryGroup], "," ),
        Control[IsFootfall] = 0
    ),
    "SecondaryGroup", CALCULATE (
        CONCATENATEX (
            VALUES ( Control[SecondaryGroup] ),
            Control[SecondaryGroup],
            ","
        ),
        Control[IsFootfall] = 0
    )
)

Thanks Zubair that is really useful, it has grouped most of them -  although its still not grouping I would expect.

 

these are my results

 

Desktop
"Desktop,Mobile"
Facebook
"Facebook,Desktop"
"Facebook,Desktop,Mobile"
"Facebook,Mobile"
"Facebook,Mobile,Desktop"
Mobile
"Mobile,Desktop"

@mcam99

 

Try this one

 

Attributes =
ADDCOLUMNS (
    GROUPBY ( Control, Control[UUID] ),
    "PrimaryGroup", CALCULATE (
        CONCATENATEX (
            VALUES ( Control[PrimaryGroup] ),
            Control[PrimaryGroup],
            ",",
            Control[PrimaryGroup]
        ),
        Control[IsFootfall] = 0
    ),
    "SecondaryGroup", CALCULATE (
        CONCATENATEX (
            VALUES ( Control[SecondaryGroup] ),
            Control[SecondaryGroup],
            ",",
            Control[SecondaryGroup]
        ),
        Control[IsFootfall] = 0
    )
)

Thats awesome, thank you!

mcam99
Frequent Visitor

I have the following query to create groups where an entity exists in more than 1 group

 

ie

User 1, Mobile

User 1, Desktop

=

User 1, Mobile,Desktop

 

My issue is where I have a different primary groups but the same secondary group it creates the following 

 

Facebook,Mobile,Mobile
Mobile
Mobile,Desktop
Mobile,Mobile

 

Where as I want the results grouped like

 

Facebook,Mobile
Mobile
Mobile,Desktop

 

Below is the current DAX syntax I am using, can anyone help ?

 

Thanks in advance

 

 

Attributes = ADDCOLUMNS(
GROUPBY(
Control,
Control[UUID]
),
"PrimaryGroup",
CALCULATE(
CONCATENATEX(Control, Control[PrimaryGroup], ","),Control[IsFootfall] = 0),
"SecondaryGroup",
CALCULATE(
CONCATENATEX(Control, Control[SecondaryGroup], ","),Control[IsFootfall] = 0)
)

 

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.