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
GlynMThomas
Resolver I
Resolver I

Max group by id and date key

Hi Guys,

 

I have a table that looks like this:

 

Reporting Group Id Investment Method Date KeyValue
1Internal20200101 50
1External20200101 100
1Internal20200201 100
1External20200201 20
1Internal20200301 500
2Internal20200101 500
2External20200101 200
2Internal20200201 300
2External20200201 50
3Internal20200101 400
3External20200101 200
3Internal20200201 100
3External20200201 300

 

I need to create a summerized table give me just the investment method by the reporting group for each date key based on the max value for each date. So the results should look like this:

 

Reporting Group Id Investment Method Date KeyValue
1External20200101 100
1Internal20200201 100
1Internal20200301 500
2Internal20200101 500
2Internal20200201 300
3Internal20200101 400
3External20200201 300

 

I'm a little bit stuck.

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

Hi @GlynMThomas 

You can build a summarize table to show max value for each ID and Date Key by summarize function.

Summarize Table = 
SUMMARIZE (
    FILTER (
        'Table',
        'Table'[Reporting Group Id ] = 'Table'[Reporting Group Id ]
            && 'Table'[Date Key] = 'Table'[Date Key]
            && 'Table'[Value]
                = MAXX (
                    FILTER (
                        'Table',
                        'Table'[Reporting Group Id ] = EARLIER ( 'Table'[Reporting Group Id ] )
                            && 'Table'[Date Key] = EARLIER ( 'Table'[Date Key] )
                    ),
                    'Table'[Value]
                )
    ),
    'Table'[Reporting Group Id ],
    'Table'[Investment Method ],
    'Table'[Date Key],
    'Table'[Value]
)

Result is as below.

1.png

You can download the pbix file from this link: Max group by id and date key

 

Best Regards,

Rico Zhou

 

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

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @GlynMThomas 

You can build a summarize table to show max value for each ID and Date Key by summarize function.

Summarize Table = 
SUMMARIZE (
    FILTER (
        'Table',
        'Table'[Reporting Group Id ] = 'Table'[Reporting Group Id ]
            && 'Table'[Date Key] = 'Table'[Date Key]
            && 'Table'[Value]
                = MAXX (
                    FILTER (
                        'Table',
                        'Table'[Reporting Group Id ] = EARLIER ( 'Table'[Reporting Group Id ] )
                            && 'Table'[Date Key] = EARLIER ( 'Table'[Date Key] )
                    ),
                    'Table'[Value]
                )
    ),
    'Table'[Reporting Group Id ],
    'Table'[Investment Method ],
    'Table'[Date Key],
    'Table'[Value]
)

Result is as below.

1.png

You can download the pbix file from this link: Max group by id and date key

 

Best Regards,

Rico Zhou

 

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

DataInsights
Super User
Super User

@GlynMThomas,

 

Try this measure:

 

Max Value =
VAR vReportingGroup =
    MAX ( GroupTest[Reporting Group Id] )
VAR vDateKey =
    MAX ( GroupTest[Date Key] )
VAR vMaxValue =
    CALCULATE (
        MAX ( GroupTest[Value] ),
        FILTER (
            ALL ( GroupTest ),
            GroupTest[Reporting Group Id] = vReportingGroup
                && GroupTest[Date Key] = vDateKey
        )
    )
VAR vResult =
    IF ( MAX ( GroupTest[Value] ) = vMaxValue, vMaxValue, BLANK () )
RETURN
    vResult

 

DataInsights_0-1606105214527.png

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.