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
rbowen
Helper I
Helper I

Find Or Filter On Maximum Transaction Number For Each Store

I have a database table coming into one of my BI Desktop reports that shows the number of transactions our customers have done at our various stores. Each customer can potentially make a purchase (transaction) at multiple stores throughout the course of any given day/month. The table below is an example of two customer accounts. 

 

rbowen_0-1709759856059.png

 

What I'm trying to do is filter the table above to show what store each customer did the most transactions with.  So, in the example above, the final result would look like this:

 

rbowen_1-1709760173305.png

 

There are several thousand customers and around 58 different stores and what I need is to find the store having the most transactions for each of those numerous customer accounts. The final result could be a measure, calculated column or even a new table (as long as it keeps the 5 columns so I can link the customer account number to other tables in the report). The report will refresh the data daily so the most used store may change for a given customer/customers over time so this has to be a dynamic solution. 

 

Any guidance would be greatly appreciated.  Thank you. 

 

 

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

Hi @rbowen ,

 

Based on the example and description you provided, Please try code as below to create measure.
My Sample:

vweiyan1msft_0-1709790933146.png

Max_Counter = 
CALCULATE (
    MAX ( 'Table'[Transaction Counter] ),
    ALLEXCEPT ( 'Table', 'Table'[Customer Number] )
)
Correspond_StoreNumber = 
MAXX (
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Customer Number] ),
        'Table'[Transaction Counter] = [Max_Counter]
    ),
    'Table'[Store Number]
)
Correspond_StoreName = 
MAXX (
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Customer Number] ),
        'Table'[Transaction Counter] = [Max_Counter]
    ),
    'Table'[Store Name]
)

Result is as below.

vweiyan1msft_1-1709790983538.png


Best Regards,
Yulia Yan


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

Hi @rbowen ,

 

Based on the example and description you provided, Please try code as below to create measure.
My Sample:

vweiyan1msft_0-1709790933146.png

Max_Counter = 
CALCULATE (
    MAX ( 'Table'[Transaction Counter] ),
    ALLEXCEPT ( 'Table', 'Table'[Customer Number] )
)
Correspond_StoreNumber = 
MAXX (
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Customer Number] ),
        'Table'[Transaction Counter] = [Max_Counter]
    ),
    'Table'[Store Number]
)
Correspond_StoreName = 
MAXX (
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Customer Number] ),
        'Table'[Transaction Counter] = [Max_Counter]
    ),
    'Table'[Store Name]
)

Result is as below.

vweiyan1msft_1-1709790983538.png


Best Regards,
Yulia Yan


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

Apologies for the lengthy delay in responding. While the measures worked, I'm finding that I need to create a separate or calculated table to get a 1 to many relationship to get the visuals working correctly. Is there a way of doing this so that I get the most used stores for each customer in a table?

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.