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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Help with grouping and concatenating!

Please and thanks in advance to someone who can help me, I have the following situation with a database that I already grouped previously:

This is the situation I am counting on

Invoice DateNIT ManagerInvoice No. Cod_AnexoGrouped Weight (Kg)NIT AND
31/03/2023358931PLF 6.610,003589
31/03/2023358931PLR 2.811,003589
18/01/2023364053PLF 2.215,009190
27/05/2023358953PLR 4.183,003589
1/06/2023358954PLR 12.393,003589
11/11/2023334554PLR 2.372,004444

But the desired situation is to be able to group the "Invoice No." column even more and have the "Cod_Anexo" data concatenated, in addition to adding the corresponding "Grouped Weight" column data, something like this:

Invoice DateNIT ManagerInvoice No. Cod_AnexoGrouped Weight (Kg)NIT AND
31/03/2023358931PLF, PLR 9.421,003589
18/01/2023364053PLF, PLR 6.398,009190
1/06/2023358954PLR 12.393,003589
11/11/2023334554PLR 2.372,00

4444

1 ACCEPTED SOLUTION
v-yifanw-msft
Community Support
Community Support

Hi @Syndicate_Admin ,
Depending on the information you provided, you can refer to the following steps:
1.Add three columns, filter results with Flag=0.

Cod_Anexo_1 = 
IF (
    CALCULATE (
        COUNT ( 'Table'[Cod_Anexo] ),
        FILTER (
            'Table',
            'Table'[Invoice No.] = EARLIER ( 'Table'[Invoice No.] )
                && 'Table'[Cod_Anexo] = EARLIER ( 'Table'[Cod_Anexo] )
        )
    ) = 2,
    'Table'[Cod_Anexo],
    'Table'[Cod_Anexo_]
)
Flag = 
VAR _1 =
    RANKX (
        FILTER ( 'Table', 'Table'[Invoice No.] = EARLIER ( 'Table'[Invoice No.] ) ),
        'Table'[Index],
        ,
        ASC
    )
VAR _2 =
    IF ( _1 = 1 || 'Table'[Cod_Anexo_1] <> "PLF,PLR", 0, 1 )
RETURN
    _2
WEIGHT = 
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[Grouped Weight (Kg)] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Invoice No.] = EARLIER ( 'Table'[Invoice No.] )
        )
    )
RETURN
    IF ( 'Table'[Cod_Anexo_1] = "PLF,PLR", _1, 'Table'[Grouped Weight (Kg)] )

vyifanwmsft_0-1709022136462.png

Final output:

vyifanwmsft_1-1709022161737.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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-yifanw-msft
Community Support
Community Support

Hi @Syndicate_Admin ,
Depending on the information you provided, you can refer to the following steps:
1.Add three columns, filter results with Flag=0.

Cod_Anexo_1 = 
IF (
    CALCULATE (
        COUNT ( 'Table'[Cod_Anexo] ),
        FILTER (
            'Table',
            'Table'[Invoice No.] = EARLIER ( 'Table'[Invoice No.] )
                && 'Table'[Cod_Anexo] = EARLIER ( 'Table'[Cod_Anexo] )
        )
    ) = 2,
    'Table'[Cod_Anexo],
    'Table'[Cod_Anexo_]
)
Flag = 
VAR _1 =
    RANKX (
        FILTER ( 'Table', 'Table'[Invoice No.] = EARLIER ( 'Table'[Invoice No.] ) ),
        'Table'[Index],
        ,
        ASC
    )
VAR _2 =
    IF ( _1 = 1 || 'Table'[Cod_Anexo_1] <> "PLF,PLR", 0, 1 )
RETURN
    _2
WEIGHT = 
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[Grouped Weight (Kg)] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Invoice No.] = EARLIER ( 'Table'[Invoice No.] )
        )
    )
RETURN
    IF ( 'Table'[Cod_Anexo_1] = "PLF,PLR", _1, 'Table'[Grouped Weight (Kg)] )

vyifanwmsft_0-1709022136462.png

Final output:

vyifanwmsft_1-1709022161737.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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

 

Ashish_Mathur
Super User
Super User

Hi,

In the result table, why do we not have 2 rows for invoice 53 when in fact Invoice Date and NIT Mangaer entries are differnet for both rows of that invoice number?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello, yes, I'm sorry, it was my mistake, they must be separated, the only one that would be grouped together would be invoice 31

Hi,

Should grouping of rows happen based on the first 3 columns?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.