Forum Discussion

rbowen's avatar
rbowen
Helper III
2 years ago
Solved

Create New Calculated Table From Existing Table With Only Maximum Value For Each Customer

I have an existing table in my BI Desktop report that has multiple customer accounts and the various store locations they've made purchases from. Here's an example of what it looks like for just two ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi rbowen 

    Yo can refer to the following code.

    Create a calculated table.

    Table 2 =
    VAR a =
        SUMMARIZE (
            'Table',
            [Customer Number],
            [Customer Name],
            "Max Tra", MAX ( 'Table'[Transaction Counter] )
        )
    RETURN
        ADDCOLUMNS (
            a,
            "Max Store Number",
                MAXX (
                    FILTER (
                        'Table',
                        [Customer Number] = EARLIER ( 'Table'[Customer Number] )
                            && [Customer Name] = EARLIER ( 'Table'[Customer Name] )
                            && [Transaction Counter] = EARLIER ( [Max Tra] )
                    ),
                    [Store Number]
                ),
            "Max Store Name",
                MAXX (
                    FILTER (
                        'Table',
                        [Customer Number] = EARLIER ( 'Table'[Customer Number] )
                            && [Customer Name] = EARLIER ( 'Table'[Customer Name] )
                            && [Transaction Counter] = EARLIER ( [Max Tra] )
                    ),
                    [Store Name]
                )
        )
    

    Output

     

    Best Regards!

    Yolo Zhu

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