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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
EVS5005
Frequent Visitor

Min value in each group that is affected by filters

Hello, I'm trying to get the max value in a group but still have it be affected by filters. 

For example, I have a table that looks like this and I want to return the maximum value of transaction source for each client

ClientTransaction DateTransaction Source
Client A2024-09-01In store
Client A2024-10-01Online
Client A2024-11-01In store
Client B2024-10-01In Store
Client B2024-11-01In Store

 

The result should be the following if there is no filter applied

ClientMax Transaction Source
Client AOnline
Client B

In Store

 

and I want the result to be the following if there is a filter on Transaction Date = 2024-11-01

ClientMax Transaction Source
Client AIn Store
Client BIn Store


I've tried using 

max transaction source = calculate(max(Overview[Transaction Source]), filter(allselected(Overview), Overview[client] = SELECTEDVALUE(Overview[client])))
but it returns blank

and

max transaction source= calculate(max(Overview[Transaction Source]), allexcept(Overview[client])) 
but it isn't filterable. 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@EVS5005 

 

Max = 
CALCULATE (
    MAX ( 'Table'[Transaction Source] ),
    TOPN (
        1, 
        FILTER ( 
            ALLSELECTED ( 'Table' ),
            'Table'[Client] = MAX ( 'Table'[Client] )
        ),
        'Table'[Transaction Source],
        DESC
    )
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

10 REPLIES 10
parry2k
Super User
Super User

@EVS5005 

 

Max = 
CALCULATE (
    MAX ( 'Table'[Transaction Source] ),
    TOPN (
        1, 
        FILTER ( 
            ALLSELECTED ( 'Table' ),
            'Table'[Client] = MAX ( 'Table'[Client] )
        ),
        'Table'[Transaction Source],
        DESC
    )
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@EVS5005 add DESC

 

Max = 
CALCULATE (
    MAX ( 'Table'[Transaction Source] ),
    TOPN (
        1, 
        ALLSELECTED ( 'Table' ),
        'Table'[Transaction Date],
        DESC
    ),
        VALUES ( 'Table'[Client] )
)

 but still not sure why you are getting Online for Client A when no filter is applied  



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Online is the max value between Online and In Store, so if both exist the output would be Online. 
This also doesn't work, its just taking the max value of everything and not grouping it by the client. It also doesn't change when I apply a filter on transaction date

The solution was based on the assumption that you are taking most recent transaction. Change the date column to source column 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

This kinda works for A, but since B doesn't have an "Online" value its being removed 

EVS5005_1-1731092097920.png

 

 

parry2k
Super User
Super User

@EVS5005 you are not explaining why you are getting online for client A, what is the logic behind it?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@EVS5005 it should work, share the sample data. in you original post this output is wrong, for client A it should be "in store" because the max date is 2024-11-01, not sure how you came up with online

 

 

Client Max Transaction Source
Client A Online
Client B

In Store



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

and I want the result to be the following if there is no filter applied

ClientMax Transaction Source
Client AOnline
Client B

In Store

 

and I want the result to be the following if there is a filter on Transaction Date = 2024-11-01

ClientMax Transaction Source
Client AIn Store
Client BIn Store
parry2k
Super User
Super User

@EVS5005 try this dax measure:

 

Max = 
CALCULATE (
    MAX ( 'Table'[Transaction Source] ),
    TOPN (
        1, 
        ALLSELECTED ( 'Table' ),
        'Table'[Transaction Date]
    ),
        VALUES ( 'Table'[Client] )
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

This doesn't work either, it just returns Online for everything

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors