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
Anonymous
Not applicable

Filtering Calculated DAX Table by Max Value in a column

Hey!

 

I have this problem that I want to filter a calculated table so that it only returns one row per customer where there is the maximum value in another column (Count column). I have tried multiple formulas for this one and also tried if ChatGBT could help me, but none has succeeded. Here is the formula that I have created by myself but it does not return the output that I want. The total assets 

 

 

Commodities per Customer =
VAR _table =
    ADDCOLUMNS (
        SUMMARIZE (
            MergedSites,
            'SVC by customer'[Business Partner],
            'SVC by customer'[Business Partner ID],
            MergedSites[Primary_Commodity]
        ),
        "Count",
            CALCULATE (
                COUNTROWS ( MergedSites )
            )
    )
RETURN
    FILTER (
        SUMMARIZE (
            _table,
            'SVC by customer'[Business Partner],
            MergedSites[Primary_Commodity],
            [Count]
        ),
        MAXX (
            _table,
            [Count]
        )
    )

 

 I would really appreciate it if someone could help me with this one.

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

Hi @Anonymous,

You can try to use the following formula if it suitable for your requirement:

Commodities per Customer =
GROUPBY (
    SUMMARIZE (
        MergedSites,
        'SVC by customer'[Business Partner],
        'SVC by customer'[Business Partner ID],
        MergedSites[Primary_Commodity],
        "Csites", COUNTROWS ( MergedSites )
    ),
    [Business Partner],
    [Business Partner ID],
    [Primary_Commodity],
    "MCsites", MAXX ( CURRENTGROUP (), [Csites] )
)

If the above expression not helps, can you please share some dummy data that keep the raw data structure with expected results? It is hard to test and modify the expressions without any sample data.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Why are you creating a calculated table?  Why not solve everything with a measure?  If my approach suits you, then share some data, describe the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

You can try to use the following formula if it suitable for your requirement:

Commodities per Customer =
GROUPBY (
    SUMMARIZE (
        MergedSites,
        'SVC by customer'[Business Partner],
        'SVC by customer'[Business Partner ID],
        MergedSites[Primary_Commodity],
        "Csites", COUNTROWS ( MergedSites )
    ),
    [Business Partner],
    [Business Partner ID],
    [Primary_Commodity],
    "MCsites", MAXX ( CURRENTGROUP (), [Csites] )
)

If the above expression not helps, can you please share some dummy data that keep the raw data structure with expected results? It is hard to test and modify the expressions without any sample data.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.

Top Solution Authors