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
Silverfeet
New Member

Grouping data in a field into multiple bins

Hello, I have Table 1 in Power BI shown below

 

Table 1
GroupNumber of Candidates
A4
B3
C6
BC8
AB12
D5
Total38

 

Group and Number of Candidates are Fields. I want to get Table 2 shown below

 

Table 2
GroupNumber of Candidates
A16
B23
C14
D5
Total58

 

So the Group field has been put into bins, for example Group A (16 candidates) in Table 2 consist of all occurrences of A in Table 1 which is A (4 candidates) and AB (12 candidates).

 

Is there any way this can be done, this would be very useful.

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Silverfeet,

 

Two solutions for your reference:

 

Solution1

You should manually create a Table2 with one single column that lists all unique group values.

1.PNG

 

Then, add a caculated column in Table2.

Number of Candidates =
CALCULATE (
    SUM ( Table1[Number of Candidates] ),
    FILTER (
        Table1,
        NOT ( ISERROR ( FIND ( EARLIER ( Table2[Group] ), Table1[Group] ) ) ) = TRUE ()
    )
)

2.PNG

 

Solution2

In Query Editor mode, duplicate Table1 first. Split the [Group] column in duplicated table 'Table1(2)'.

3.PNG

 

Save above changes. In Data view mode, new a calculated table with below formula:

Table1(3) =
SUMMARIZE (
    FILTER (
        UNION (
            SELECTCOLUMNS (
                'Table1 (2)',
                "Group", 'Table1 (2)'[Group.1],
                "Number", 'Table1 (2)'[Number of Candidates]
            ),
            SELECTCOLUMNS (
                'Table1 (2)',
                "Group", 'Table1 (2)'[Group.2],
                "Number of Candidates", 'Table1 (2)'[Number of Candidates]
            )
        ),
        [Group] <> BLANK ()
    ),
    [Group],
    "Number of Candidates", SUM ( 'Table1 (2)'[Number of Candidates] )
)

4.PNG

 

Best regards,

Yuliana Gu

 

 

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Silverfeet,

 

Two solutions for your reference:

 

Solution1

You should manually create a Table2 with one single column that lists all unique group values.

1.PNG

 

Then, add a caculated column in Table2.

Number of Candidates =
CALCULATE (
    SUM ( Table1[Number of Candidates] ),
    FILTER (
        Table1,
        NOT ( ISERROR ( FIND ( EARLIER ( Table2[Group] ), Table1[Group] ) ) ) = TRUE ()
    )
)

2.PNG

 

Solution2

In Query Editor mode, duplicate Table1 first. Split the [Group] column in duplicated table 'Table1(2)'.

3.PNG

 

Save above changes. In Data view mode, new a calculated table with below formula:

Table1(3) =
SUMMARIZE (
    FILTER (
        UNION (
            SELECTCOLUMNS (
                'Table1 (2)',
                "Group", 'Table1 (2)'[Group.1],
                "Number", 'Table1 (2)'[Number of Candidates]
            ),
            SELECTCOLUMNS (
                'Table1 (2)',
                "Group", 'Table1 (2)'[Group.2],
                "Number of Candidates", 'Table1 (2)'[Number of Candidates]
            )
        ),
        [Group] <> BLANK ()
    ),
    [Group],
    "Number of Candidates", SUM ( 'Table1 (2)'[Number of Candidates] )
)

4.PNG

 

Best regards,

Yuliana Gu

 

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.